如何在 SQL Server 2008 中进行分页?
最佳答案
您可以使用ROW_NUMBER() :
Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.
示例:
WITH CTEResults AS
(
SELECT IDColumn, SomeField, DateField, ROW_NUMBER() OVER (ORDER BY DateField) AS RowNum
FROM MyTable
)
SELECT *
FROM CTEResults
WHERE RowNum BETWEEN 10 AND 20;
关于sql - 如何在SQL Server 2008中进行分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2244322/