- 论坛徽章:
- 0
|
如何取oracle表中符合条件一定条数范围内的记录
rownum要从1开始的,故不能用>;,('>;0'除外,因为这个条件实际上也是从1开始),另外,rownum并非不可以跟其它条件在一起啊.
- select a.num from (select rownum as num from test_table where rownum<=10) where a.num>;1 and a.num<10 order by a.last_update;
复制代码
SQL>; select rownum as num,lab_num,test_date from mastresult where rownum<11 order by test_date;
NUM LAB_NUM TEST_DATE
---------- ---------------- -------------------
1 03000034 2003-01-13 16:27:45
2 03000034 2003-01-13 16:27:45
3 03000034 2003-01-13 16:27:45
4 03000034 2003-01-13 16:27:45
5 03000034 2003-01-13 16:27:45
6 03000035 2003-01-14 08:51:31
7 03000035 2003-01-14 08:51:31
8 03000035 2003-01-14 08:51:31
9 03000035 2003-01-14 08:51:31
10 03000035 2003-01-14 08:51:31
已选择10行。
SQL>; select a.num,a.lab_num,a.test_date from (select rownum as num,lab_num,test_date from mastresult where rownum<11 ) a
where a.num>;1 and a.num<10 order by a.test_date;
NUM LAB_NUM TEST_DATE
---------- ---------------- -------------------
2 03000034 2003-01-13 16:27:45
3 03000034 2003-01-13 16:27:45
4 03000034 2003-01-13 16:27:45
5 03000034 2003-01-13 16:27:45
6 03000035 2003-01-14 08:51:31
7 03000035 2003-01-14 08:51:31
8 03000035 2003-01-14 08:51:31
9 03000035 2003-01-14 08:51:31
已选择8行。 |
|