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 關注
- 799 瀏覽
添加回答
舉報
0/150
提交
取消