oracle 数据库 分页排序问题 求指教
没对表做过主外键 索引
select * from sdata order by spid desc
单独排序的话是没问题的 但是加到分页sql里查出来就是不规则的 以下是sql语句
select * from (select * from sdata order by spid desc) where rownum <= '10'
minus
select * from (select * from sdata order by spid desc) where rownum <= '5';
求高手帮忙给分析下 为什么不排序 做好是能给出解决方法
------解决方案--------------------
跟order by和rownum的执行方式有关吧
给select * from sdata order by spid desc建个视图,然后对视图分页,应该可以
------解决方案--------------------select * from (select *, rownum AS rn from sdata order by spid desc) WHERE rn BETWEEN ... AND ... ORDER BY rn
------解决方案--------------------select * from
(
select rownum rn,* from sdata order by spid desc) where rownum <= '10'
)t where rn>=5;