Sqlserver分页查询语句

Sql server分页查询语句

  PageSize:每页显示几条数据 

  pageNumber:当前页索引

  T为表

  注:通常pageNumber索引从零开始

  

select * from t where Id in 

( select top pageSize Id from 
(select top (pageSize*(pageNumber+1)) UnitId from t order by Id asc) t
order by t.Id desc)order by Id asc

  pagnumbver:当前页

  注:pageNumber索引从壹开始

select * from t where Id in 
( select top pageSize Id from 
(select top (pageSize*(pageNumber)) UnitId from t order by Id asc) t
order by t.Id desc)order by Id asc

转载于:https://www.cnblogs.com/huoyuqing/p/10838534.html

你可能感兴趣的:(Sqlserver分页查询语句)