高分求助??????

zhong00000 2003-02-28 10:50:19
求助!用SQL语句查询,怎么控制返回第n行到第s行?

就是

SELECT *
FROM AAA

想取出地30行到第60行的数???
...全文
20 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
angle1219 2003-02-28
  • 打赏
  • 举报
回复
昨天刚看到这个内容的,你找一下
lanzhousunbo 2003-02-28
  • 打赏
  • 举报
回复
大力没来呀?
nik_Amis 2003-02-28
  • 打赏
  • 举报
回复
up
CrazyFor 2003-02-28
  • 打赏
  • 举报
回复
查询N-M条记录。
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
select top M * from #temptable where iid>=N

OR:

select top M * from yourTable where id not in(select top N-1 id from table)
ID为表具有唯一值的任何字段
九道咨询 2003-02-28
  • 打赏
  • 举报
回复
这种情况一般只有写个存储过程来做了。
wingspread 2003-02-28
  • 打赏
  • 举报
回复
create table zz(i integer)
go
declare @i integer
while @i<100
begin
insert into zz values(@i)
select @i=@i+1
end
go
select * from zz where
(i in (select top 60 * from zz))
and (i not in (select top 30 * from zz))


实际应用的时候加上order字句就可以了

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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