请问各位大狭这句很简单要求的sql怎么写?谢谢 ^0^

taojm 2003-10-17 07:06:43
有一个表叫table
其中有一个字段叫name
表中如果有1万条数据,我想抽取第5000条到5020条数据
这个要求的sql怎么写啊?
...全文
35 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tsj68 2003-10-18
  • 打赏
  • 举报
回复
修正如下:
select * from (select rownum rn,table.* from table where rownum<5021)
where rn>4999
这样效率高一些,只扫描前5021条记录,如果是大表,可以节省很多时间.
tsj68 2003-10-18
  • 打赏
  • 举报
回复
select * from (select rownum rn,table.* from table where rownum<5021)
where rn>4999
这样效率高一些,只扫描前5000条记录,如果是大表,可以节省很多时间.
astroboy 2003-10-18
  • 打赏
  • 举报
回复
我记得在sql-server中有个bengin...and,
不知道行不行,我没试过
podded 2003-10-18
  • 打赏
  • 举报
回复
"第5000条到5020条数据"是随便20条还是固定的20条数据呢?



Delphi_Li 2003-10-18
  • 打赏
  • 举报
回复
Oracle中的数据是随机存储的,每次的选择可能结果都不一样!!!
welyngj 2003-10-17
  • 打赏
  • 举报
回复
1 select * from tbl1 where rownum<6 minus
2* select * from tbl1 where rownum<2

ID A
-------- ----------
2 1a
3 1a
4 1a
5 1a
jiezhi 2003-10-17
  • 打赏
  • 举报
回复
1. select ... where rownum<=m
minus
select ... where rownum<n
2.use rowid
taojm 2003-10-17
  • 打赏
  • 举报
回复
首先select name from table where rownum<5020 and rownum>5000是不对的
其次select * from (select name,rownum rm from table) where rm>=5000 and rm<=5020
在算法上不好,还有什么好点的方法吗?
mcyy 2003-10-17
  • 打赏
  • 举报
回复
select name from table
where deptno<5020 and deptno>5000;
welyngj 2003-10-17
  • 打赏
  • 举报
回复
select name from table where rownum<5020 and rownum>5000
beckhambobo 2003-10-17
  • 打赏
  • 举报
回复
select * from (select name,rownum rm from table) where rm>=5000 and rm<=5020
yang505412 2003-10-17
  • 打赏
  • 举报
回复
select name from table where recno<5020 and recno>5000
好象是吧,不太记得了

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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