select * from (select A.*,ROWNUM from(select * from test) A where rownum <= 40) where rownum >= 20 我test表中有几十万条数据,这个分页查询为什么查不好数据,
互换的青春
浏览 777回答 1
1回答
翻过高山走不出你
ROWNUM是伪列,只能<=,不能>=所以需要给ROWNUM起个别名,变成逻辑列后来比较select *from (select rownum as num,a.* from (select * from test order by 1 asc) a) twhere t.num>=20and t.num<=40;你写的可以修改为:select * from (select ROWNUM as num,A.* from (select * from test) A where rownum <= 40)where num >= 20;