标签:
1 USE AdventureWorks2012; 2 GO 3 4 DECLARE @PageSize int = 100, @PageNumber int = 3; 5 6 WITH Product_CTE 7 AS 8 ( 9 SELECT Name 10 ,ProductNumber 11 ,StandardCost 12 ,ListPrice 13 ,SellStartDate 14 ,ROW_NUMBER() OVER(ORDER BY ProductID) AS RowNumber 15 ,COUNT(*) OVER() AS TotalCount 16 FROM Production.Product 17 ) 18 SELECT * 19 FROM Product_CTE 20 WHERE RowNumber BETWEEN @PageSize * (@PageNumber - 1) + 1 AND @PageSize * @PageNumber;
标签:
原文地址:http://www.cnblogs.com/yersans/p/5467708.html