mssql 取数据指定条数(例:100-200条的数据)
方法1:临时表
select top 200 * into #aa from table order by time-- 将top m笔插入 临时表 set rowcount 100 select * from #aa order by time desc --drop table #aa --删除临时表
方法2:
1 select top 100 * from 2 (select top 200 * from table order by time asc) 3 order by time desc
方法3: not in
1 select top 100 * from v_company where ( 2 id not in 3 (select top 100 id from v_company order by id asc) 4 ) order by id asc
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】开源 Linux 服务器运维管理面板 1Panel V2 版本正式发布
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步