sqlserver分页查询语法
程序员文章站
2024-02-22 23:40:46
...
1.过滤前10条数据,取的5条数据。(注意:sqlserver 2012以上版本可用)
select * form [dbo].[Student] order by Id offset 10 rows fetch next 5 rows only
2.查询结果重新排序Id列,取Ids值包含
select * from (select Row_Num() over(order by Id) ids,* from [dbo].[Student] Test where Ids between 11 and 15)
3.查询前5条,但是Id不包括前10条
select top 5 * from [dbo].[Student] where Id not in (select top 10 Id from [dbo].[Student] )