原始的sql是这样的:
select * from( select tmp.*,rownum rn from( select * from table1 where column1 =‘12345‘ order by column2,column3 desc ) tmp where rownum<=30 ) where rn>20
问题:在我的项目中,当rownum<=20 , rn>10的数据和rownum<=30 , rn>20的数据一样。
解决办法:后来在order by 的列上加了id ,就可以了,如下:
select * from( select tmp.*,rownum rn from( select * from table1 where column1 =‘12345‘ order by column2,column3 desc,id ) tmp where rownum<=30 ) where rn>20