oracle分页的两种方式

来源:互联网 发布:道亨软件 编辑:程序博客网 时间:2024/05/17 06:49

方式一:

select * from (

select rownum r e.empno from ( select * from emp order by sal desc) e

)
where r>=5 and r<=8

注:在oracle中rownum永远是从1开始的,所以where条件不能 使用>、>=(比如:盖8层楼,1234层都没有盖,怎么能盖5678呢?大概就是这个意思。说的不对,赶紧提出来哦)

方式二:

select * from (

select rownum r, e1.empno from (select * from emp order by sal desc ) e1 where rownum<=8

) e2
where r>=5;

0 0