Following is the code snippet to show how quick and simply pagination can be done using OVER:
USE northwind
DECLARE @startIndex INT,
@pageLength INT
SET @startIndex = 6
SET @pageLength = 5
SELECT *
FROM (SELECT o.shipname,
o.shipaddress,
Row_number()
OVER(ORDER BY o.customerid DESC) AS rownumber
FROM orders AS o
JOIN [order details] AS od
ON od.orderid = o.orderid
WHERE o.customerid = 'VINET') AS shipmentdetail
WHERE rownumber BETWEEN @startIndex AND (@startIndex + @pageLength - 1)
1 comment:
Hi Ashish...nice blog! I am looking for a Technical Architect and you seem to fit the profile. The position is based in Noida. If you may be interested drop me an email at sbc.r2i@gmail.com with your contact info so that we can discuss this position in detail.
Thanks,
Swaty
http://www.linkedin.com/pub/1/657/b61
Post a Comment