ROWNUM的问题 SQL如下: select tab_.*, rownum rownum_ from (SELECT ta.platform_name, NVL(a.sum, 0) AS sum FROM LCOP_PLATFORM_TAB ta LEFT JOIN (SELECT t.platform_id, count(1) AS sum FROM LCOP_USER_TEST t where SUBSTR(t.timestamp, 1, 6) < = SUBSTR(to_char(to_date('2012-05-12', 'yyyy-mm-dd'), 'yyyymmdd'), 1, 6) GROUP BY t.platform_id) a ON a.platform_id = ta.platform_id ORDER BY a.sum desc) tab_ where rownum <= 10
执行 SELECT ta.platform_name, NVL(a.sum, 0) AS sum FROM LCOP_PLATFORM_TAB ta LEFT JOIN (SELECT t.platform_id, count(1) AS sum FROM LCOP_USER_TEST t where SUBSTR(t.timestamp, 1, 6) < = SUBSTR(to_char(to_date('2012-05-12', 'yyyy-mm-dd'), 'yyyymmdd'), 1, 6) GROUP BY t.platform_id) a ON a.platform_id = ta.platform_id ORDER BY a.sum desc