select * from (select A.*,ROWNUM from(select * from test) A where rownum <= 40) where rownum >= 20我test表中有幾十萬(wàn)條數(shù)據(jù),這個(gè)分頁(yè)查詢?yōu)槭裁床椴缓脭?shù)據(jù),
1 回答

翻過(guò)高山走不出你
TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個(gè)贊
ROWNUM是偽列,只能<=,不能>=
所以需要給ROWNUM起個(gè)別名,變成邏輯列后來(lái)比較
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 關(guān)注
- 808 瀏覽
添加回答
舉報(bào)
0/150
提交
取消