怎么查询排序后结果集的前N条记录?
(select * from tb1 order by field1 desc) select A.* from(select rownum rid,tb1.* from tb1 order by field1 desc) A
where A.rid<N+1 直接在末尾用rownum<=N(N為所要的記錄數)!
如:
select * from students
order by std_id
where rownum<=10; table A
col1 col2
a 3
c 2
d 5
select col1,ol2,rank() over( oder by col2 ) where rownum<2;
页:
[1]