方法一:
--分页方法一select top 10 OrderID,CustomerID, EmployeeID,OrderDate,ShippedDate,ShipName,ShipAddress,Freightfrom [Orders] where OrderID not in(select top 100 OrderID from [Orders] order by OrderID)
方法二:
--分页方法二select * from (select OrderID,CustomerID, EmployeeID,OrderDate,ShippedDate,ShipName,ShipAddress,Freight,ROW_NUMBER() over(order by OrderID) as rn from [Orders]) as twhere t.rn between 101 and 110
两种方法,查询结果是一模一样的。但是查询效率,第二种方法比较高,不信你看:
执行计划:
方法一的查询开销是71%,
方法二的查询开销是29%。