日期:2014-05-17 浏览次数:21121 次
SELECT COUNT(*) FROM employees;
COUNT(*)
----------
61
SELECT n.employee_id
FROM (SELECT m.employee_id,
ROWNUM rn
FROM (SELECT t.employee_id
FROM employees t
ORDER BY t.employee_id) m
WHERE ROWNUM <= 4) n
WHERE n.rn >= 2
EMPLOYEE_ID
-----------
2
3
4
SELECT n.employee_id,
n.total_cnt
FROM (SELECT m.employee_id,
m.total_cnt,
ROWNUM rn
FROM (SELECT t.employee_id,
COUNT(*) OVER() total_cnt
FROM employees t
ORDER BY t.employee_id) m
WHERE ROWNUM <= 4) n
WHERE n.rn >= 2
EMPLOYEE_ID TOTAL_CNT
----------- ----------
2 61
3 61
4 61