最简洁的写法; select col1,col2... from ( select rownum as r col1,col2... from your_table where rownum<=100 and yourcondition) where r between 30 and 50;对于大数据量来说,子查询返回rowid效率更高: select col1,col2... from your_table where rowid in ( select rid from( select rowid as rid ,rownum as r from your_table where rownum<=100 and yourcontidion) where r between 30 and 50) ;
select * from table_name where row_num<=50 minus select * from table_name where row_num <30
Oracle中用RowNum来实现
select col1,col2... from (
select rownum as r col1,col2... from your_table where rownum<=100 and yourcondition)
where r between 30 and 50;对于大数据量来说,子查询返回rowid效率更高:
select col1,col2... from your_table where rowid in (
select rid from(
select rowid as rid ,rownum as r from your_table
where rownum<=100 and yourcontidion)
where r between 30 and 50)
;
minus
select * from table_name where row_num <30