不能直接用rownum,要查詢出來以後用別名轉換。
以EMP表為范例,取4至10行:
select * from (select rownum id,t.* from emp t) where id between 4 and 10;
有需要排序的,一定要這樣處理:
select * from ( select rownum rn,t.* from ( select a.* from eba02 a order by eba003) t where rownum <= 110) where rn >= 110;
select * from (select rownum num, a.* from table1 order by 排序關鍵字)
where num<11
”剩下的記錄正常在下面排序“按照什麼排序呢?還是id?
select * from 表 where id = xx
union all
select * from 表 where id <> xx
如果是按照主鍵id排序的話,數據庫應該會自動幫你排序的