代码
WITH
OrderedOrders
AS
( SELECT SalesOrderID, OrderDate,
ROW_NUMBER() OVER ( order by OrderDate) as RowNumber
FROM Sales.SalesOrderHeader )
SELECT *
FROM OrderedOrders
WHERE RowNumber between 50 and 60 ;
( SELECT SalesOrderID, OrderDate,
ROW_NUMBER() OVER ( order by OrderDate) as RowNumber
FROM Sales.SalesOrderHeader )
SELECT *
FROM OrderedOrders
WHERE RowNumber between 50 and 60 ;
with可以给结果集重命个名;
2005新增加的函数ROW_NUMBER()可以计算行数,再分页
select
*
from
(
select
*
,row_number()
over
(
order
by
english)
as
rownumber
from stu_score) as c where rownumber between 50 and 100
from stu_score) as c where rownumber between 50 and 100