如何按行查找数据

clear_zero 2004-12-01 07:28:32
表格中有3000行数据,我想找1100-1600行之间的数据,如何查找呢?

推而广之,我想找从某行开始的100行数据,如何找呢?

谢谢
...全文
82 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jacksom 2004-12-01
  • 打赏
  • 举报
回复
可以这样做:从数据表中取出第n条到第m条的记录方法:
  其中id为表的关键字。
   select top m-n+1 from table
where (id not in(select top (n-1) id from table))
本人已试过多次,很好用。如有不懂可mail给我一起交流。jacksomly@163.com
yingqing 2004-12-01
  • 打赏
  • 举报
回复
給個例子,呵呵,希望你能夠看明白
select * from
(select count(*) as rank, a.num,a.ch from test a,test b where a.num>=b.num
group by a.num,a.ch order by count(*) )
where rank>=1600 and rank<=1100
clear_zero 2004-12-01
  • 打赏
  • 举报
回复
要是没有主键呢?
xingfuniao 2004-12-01
  • 打赏
  • 举报
回复
select top 1600-1100 * from t
where 主键列 not in (select top 1100 主键列 from t)

34,577

社区成员

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

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