Oracle 12C -- top-n查询新特性
在12C中,增加了一些新的特性。可以指定返回结果集的指定数量的行、或按照百分比返回行。
SQL> select count(*) from emp; COUNT(*) ---------- 14 SQL> select empno,hiredate from emp order by hiredate; EMPNO HIREDATE ---------- --------- 7369 17-DEC-80 7499 20-FEB-81 7521 22-FEB-81 7566 02-APR-81 7698 01-MAY-81 7782 09-JUN-81 7844 08-SEP-81 7654 28-SEP-81 7839 17-NOV-81 7900 03-DEC-81 7902 03-DEC-81 EMPNO HIREDATE ---------- --------- 7934 23-JAN-82 7788 19-APR-87 7876 23-MAY-87 14 rows selected. SQL> select empno,hiredate from emp order by hiredate offset 8 rows; EMPNO HIREDATE ---------- --------- 7839 17-NOV-81 7900 03-DEC-81 7902 03-DEC-81 7934 23-JAN-82 7788 19-APR-87 7876 23-MAY-87 6 rows selected. SQL> select empno,hiredate from emp order by hiredate fetch first 25 percent rows only; EMPNO HIREDATE ---------- --------- 7369 17-DEC-80 7499 20-FEB-81 7521 22-FEB-81 7566 02-APR-81 SQL>