1.rownum 分页:
(select * from emp)
2.显示rownum [oracle 分配的]
select a1.*,rownum rn from (select * from emp ) a1
3. 显示rownum 》6 《=10
select a1.*,rownum rn from (select * from emp ) a1 where rownum<=10;
select * from (select a1.*,rownum rn from (select * from emp ) a1 where rownum<=10) where rn>=6;
4.几个查询的变化
a. 指定查询的列,只需要修改最里层的子查询;
select * from (select a1.*,rownum rn from (select ename,sal from emp ) a1 where rownum<=10) where rn>=6;
b.如何排系,只需要修改最里层的子查询 order by :
select * from (select a1.*,rownum rn from (select ename,sal from emp order by sal ) a1 where rownum<=10) where rn>=6;
select * from (select a1.*,rownum rn from (select ename,sal from emp order by sal desc ) a1 where rownum<=10) where rn>=6;