ORACLE语法(1):查询第n条到第m条的数据记录的方法

1、查询前10条记录

select * from A where rownum <=10


2、查询第11条到20条记录

方法一:(select * from A where rownum <= 20) minus (select * from A where rownum <= 10)
说明 :minus 关键字的意思是求两个结果集的差集,在数学中有这个概念,比如说两个集合可以合并、公有、差集.

方法二:select * from (select * from A where rownum < 20) b where b.id not in(select id from A where rownum <10) 

说明:主要运用了not in运算符

你可能感兴趣的:(ORACLE语法(1):查询第n条到第m条的数据记录的方法)