下面是Oracle分页简单事例图片以及代码:
1、普通查询
select * from table_Name t order by active_count desc;
2、查询第一条记录
select * from (select * from table_Name order by active_count desc) where rownum = 1;
查询前3条:类似Sqlserver中的TOP 3
select * from (select * from table_Name order by active_count desc) where rownum4、查询第2至第3条记录select * from (select t.*, rownum as no from (select * from table_Name order by active_count desc) t) where no between 2 and 35、在TOP3条记录的基础上查询第2至第3条记录select * from (select t.*, rownum as no from (select * from table_Name order by active_count desc) t where rownum6、查询第2条以后的记录select * from (select t.*, rownum as no from (select * from table_Name order by active_count desc) t) where no >=2解释:
rownum 是在已产生数据的基础上伪生成的编号,所以 使用rownum 必须在已有数据的基础上,因此Oracle分页才加入了多个子查询。
我的微信
微信号已复制
我的微信
这是我的微信扫一扫