rownum问题--如何查询表中第90条到100条的记录

panweiwebweb 2007-03-13 03:48:10
能否讲解一下 rownum?最好来个例子
rownum问题--如何查询表中第90条到100条的记录

...全文
338 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
liujun1979 2007-03-17
  • 打赏
  • 举报
回复
select rw ,e.* from (select rownum rw ,lname,fname from abc where rownum<=100 order by lname) where rw>=90

如果表abc有lname的索引,这条SQL就可以取以lname排序的第90到第100行记录。
windyupeng 2007-03-17
  • 打赏
  • 举报
回复
select rw ,e.* from (select rownum rw ,lname,fname from abc where rownum<30) where rw>=0


-------------------------

不知道e . 是从那里来的 是abc 这个表吗?
dennyjava 2007-03-16
  • 打赏
  • 举报
回复
up...
bj_cash2006 2007-03-14
  • 打赏
  • 举报
回复
恩 学习
liliang9981 2007-03-14
  • 打赏
  • 举报
回复
select * from tab where rownum < 101
minus
select * from tab where rownum<89;
pdw2009 2007-03-14
  • 打赏
  • 举报
回复
select rw ,e.* from (select rownum rw ,lname,fname from abc where rownum<30) where rw>=0

这样的写法速度才是最快的.
select * from tab where rownum < 101
minus
select * from tab where rownum<89;
minus运算效率太慢了...
tgm78 2007-03-13
  • 打赏
  • 举报
回复
举个例子

select r,e.* from (select rownum r,last_name,salary from (
select last_name,salary from employees order by nvl(salary,0) desc)) e
where r between 90 and 100;
yuyu1980 2007-03-13
  • 打赏
  • 举报
回复
第二个是错误的
yuyu1980 2007-03-13
  • 打赏
  • 举报
回复
select * from
(select rownum jl,a.* from tzb a)
where jl between 90 and 100

或者
select * from tab
where rownum < 100 and not exists
(select 1 from tab where rownum<90)

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧