??SQL Server???????
???????????? ???????[ 2014/5/5 9:53:54 ] ????????SQL Server ?????
???????????????????????????????????ORM?????????LINQ????????Skip??Take?????????????????????????????洢????????????SQLServer?????洢???????????????к??????????????????????????????????θ?Ч???????????????????????????????????????????????????????????????
????? ????
??????????SQLServer??????????NorthWind??????????????Product????????????????????????UnitPrice???????У????????????10???????????????????????????????????
?????? ???
????Top???
????????????????????????????Top?????? ?????????????????C#???????????????????? ???????????????????? * ????????????????滻???????????????????????ɡ?
SELECT TOP (@pageSize)
*
FROM ( SELECT TOP ( @pageSize * @pageIndex )
*
FROM [Northwind].[dbo].[Products]
ORDER BY UnitPrice DESC
) AS product
ORDER BY product.UnitPrice
????????????????????????????????λ????????С?????????????????С????????????????????????????????????????磬????????????Products???? 77 ???????????10?????????8????÷???7?????????9???÷????????????????????????ζ?????10???????
??????????????·????????????????2???????Select????????????м?????????????????????Top PageSize??????NOT IN ??????????е?????????????????NOT IN?????????????????е?bug
SELECT *
FROM dbo.Products
WHERE ProductID IN (
SELECT TOP ( @pageSize )
ProductID
FROM dbo.Products
WHERE ProductID NOT IN ( SELECT TOP ( @pageSize * (@pageIndex-1) )
ProductID
FROM dbo.Products
ORDER BY UnitPrice DESC )
ORDER BY dbo.Products.UnitPrice DESC )
ORDER BY dbo.Products.UnitPrice ASC
???????ROW_NUMBER ???????
????????????????????·???????????????????????д???????????????????а???????????У????????У?????????????????????????????????????У??????????????????к????????????????SQLServer 2000?У?????????????????????????????????????????????????????Ч?????????????????
??????SQLServer2005????????ROW_NUMBER() ?????????????????????????????????????ι???????????????????÷????
????SELECT ROW_NUMBER() OVER ( ORDER BY dbo.Products.ProductID DESC ) AS rownum ??
????*
????FROM dbo.Products
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11