求教,SQL Server中如何返回指定的第n到m行的记录?或查询时自动添加行号?

kaienli 2004-12-23 09:07:33
例如,我只想要按时间排序后的第5到底10行记录?
...全文
140 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
haoli_004 2004-12-23
  • 打赏
  • 举报
回复
create table aa([ID] [int] IDENTITY (1, 1) NOT NULL ,查询表cc中的所有字段)

insert into aa(查询表cc中的所有字段)select cc.字段 from 查询表cc order by [time]

select aa.(查询表cc中的所有字段) from aa where [id]>4 and [id]<11

drop table aa
didoleo 2004-12-23
  • 打赏
  • 举报
回复
select * from test a
where (select count(*) from test where 时间字段<=a.时间字段) in(5,10)
Frewin 2004-12-23
  • 打赏
  • 举报
回复
Select a.*,(Select Count(*) As id from t where t.日期<=a.日期) as fid from t a
Where (Select Count(*) As id from t where t.日期<=a.日期) Between 5 and 10
order by a.日期
NinGoo 2004-12-23
  • 打赏
  • 举报
回复
参考
http://community.csdn.net/Expert/topic/3666/3666152.xml?temp=.3363306

34,590

社区成员

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

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