1 2 3 4 | SELECT 列名1...列名n FROM (SELECT 列名1...列名n FROM 表名 ORDER BY 列名1...列名n) WHERE ROWNUM <= N(抽出记录数) ORDER BY ROWNUM ASC |
1 2 3 4 | SELECT * FROM (SELECT * FROM CUSTOMER ORDER BY NAME) WHERE ROWNUM <= 3 ORDER BY ROWNUM ASC |
1 2 3 4 5 6 7 8 | SELECT 列名1...列名n FROM ( SELECT ROWNUM RECNO, 列名1...列名nFROM (SELECT 列名1...列名n FROM 表名 ORDER BY 列名1...列名n) WHERE ROWNUM <= N(抽出记录数) ORDER BY ROWNUM ASC ) WHERE RECNO = M(M <= N) |
1 2 3 4 5 6 7 | SELECT ID, NAME FROM ( SELECT ROWNUM RECNO, ID, NAME FROM (SELECT * FROM CUSTOMER ORDER BY NAME) WHERE ROWNUM <= 3 ORDER BY ROWNUM ASC ) WHERE RECNO = 2 |
1 2 3 4 5 6 7 8 | SELECT 列名1...列名n FROM ( SELECT ROWNUM RECNO, 列名1...列名nFROM (SELECT 列名1...列名n FROM 表名 ORDER BY 列名1...列名n) WHERE ROWNUM <= N(抽出记录数) ORDER BY ROWNUM ASC ) WHERE RECNO = N |
1 2 3 4 5 6 7 8 | SELECT ID, NAME FROM ( SELECT ROWNUM RECNO, ID, NAME FROM (SELECT * FROM CUSTOMER ORDER BY NAME) WHERE ROWNUM <= 2 ORDER BY ROWNUM ASC ) WHERE RECNO = 2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | SELECT 列名1...列名n FROM ( SELECT ROWNUM RECNO, 列名1...列名nFROM ( SELECT 列名1...列名n FROM 表名 ORDER BY 列名1...列名n) WHERE ROWNUM <= N (N >= (M + X - 1)) ORDER BY ROWNUM ASC ) WHERE RECNO BETWEEN M AND (M + X - 1) 同样以上面的数据为例,则抽取NAME的字母顺的第2条记录开始的3条记录的SQL语句为: SELECT ID, NAME FROM ( SELECT ROWNUM RECNO, ID, NAME FROM (SELECT * FROM CUSTOMER ORDER BY NAME) WHERE ROWNUM <= (2 + 3 - 1) ORDER BY ROWNUM ASC ) WHERE RECNO BETWEEN 2 AND (2 + 3 - 1) |
张兴康 发表于 2017-2-4 13:41
打酱油勒,打酱油勒...
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://bbs.delit.cn/) | Powered by Discuz! X3.2 |