All pastes #280376 Raw Edit

Untitled

public php v1 · immutable
·published 2006-12-15 21:30 UTC
rendered paste body
SELECT  pt.entry_id, pt.entry_subject, et.entry_text,       pt.when_posted AS time,       u.username AS owner_name,        decode(pt.tag_1, NULL, '', '<category domain=\"http://www.sportingnews.com/tag/'||pt.tag_1||'\">'||pt.tag_1||'</category>') ||       decode(pt.tag_2, NULL, '', '<category domain=\"http://www.sportingnews.com/tag/'||pt.tag_2||'\">'||pt.tag_2||'</category>') ||       decode(pt.tag_3, NULL, '', '<category domain=\"http://www.sportingnews.com/tag/'||pt.tag_3||'\">'||pt.tag_3||'</category>') ||       decode(pt.tag_4, NULL, '', '<category domain=\"http://www.sportingnews.com/tag/'||pt.tag_4||'\">'||pt.tag_4||'</category>') ||       decode(pt.tag_5, NULL, '', '<category domain=\"http://www.sportingnews.com/tag/'||pt.tag_5||'\">'||pt.tag_5||'</category>') ||       decode(pt.tag_6, NULL, '', '<category domain=\"http://www.sportingnews.com/tag/'||pt.tag_6||'\">'||pt.tag_6||'</category>') AS tags  FROM (SELECT   entry_id, entry_subject, when_posted,                 MAX (DECODE (seq, 1, tag_desc, NULL)) tag_1,                 MAX (DECODE (seq, 2, tag_desc, NULL)) tag_2,                 MAX (DECODE (seq, 3, tag_desc, NULL)) tag_3,                 MAX (DECODE (seq, 4, tag_desc, NULL)) tag_4,                 MAX (DECODE (seq, 5, tag_desc, NULL)) tag_5,                 MAX (DECODE (seq, 6, tag_desc, NULL)) tag_6            FROM (SELECT e.entry_id, d.tag_desc, entry_subject, when_posted,                         ROW_NUMBER () OVER (PARTITION BY e.entry_id                          ORDER BY d.tag_desc ASC NULLS LAST) seq           FROM (SELECT *                            FROM (SELECT a.*, ROWNUM rn                                    FROM (                                       SELECT *                                         FROM phpbb_weblog_entries e, phpbb_users u                                        WHERE u.user_weblog = e.weblog_id                                          AND u.user_id = :OWNER_ID                                          AND e.entry_access <= 1                                          ORDER BY when_posted DESC) a                                   WHERE ROWNUM <= 5)                           WHERE rn >= 1) e,                         tsn_tags_links l,                         tsn_tags_desc d                   WHERE e.entry_id = l.entry_id(+)                     AND l.tag_id = d.tag_id(+))           WHERE seq <= 6        GROUP BY entry_id,                 entry_subject,                 when_posted) pt,       phpbb_weblog_entries et,   phpbb_users u WHERE pt.entry_id = et.entry_id   AND u.user_weblog = et.weblog_idORDER BY et.when_posted DESC NULLS LAST