declare @PageSize int,@PageIndex int;
set @PageSize=5;
set @PageIndex=2;
WITH Pagination AS
(
SELECT *,ROW_NUMBER() OVER(ORDER BY PGTQ) AS RowNumber
FROM 表 where 条件
)
SELECT * FROM Pagination WHERE RowNumber
BETWEEN @PageSize*(@PageIndex-1) + 1 AND @PageSize * @PageIndex;
结果为 每页显示5条,第二页的数据