select * from (select A.*,ROWNUM from(select * from test) A where rownum <= 40) where rownum >= 20我test表中有几十万条数据,这个分页查询为什么查不好数据,
1 回答
翻过高山走不出你
TA贡献1875条经验 获得超3个赞
ROWNUM是伪列,只能<=,不能>=
所以需要给ROWNUM起个别名,变成逻辑列后来比较
select *
from (select rownum as num,a.* from (select * from test order by 1 asc) a) t
where t.num>=20
and t.num<=40;
你写的可以修改为:
select *
from (select ROWNUM as num,A.* from (select * from test) A where rownum <= 40)
where num >= 20;
- 1 回答
- 0 关注
- 770 浏览
添加回答
举报
0/150
提交
取消