Friday, June 15, 2012

the "pagination" query

This fascinating exchange led me to the following query which will work against this table to return the next 7 rows after the first 4 rows.

select top(7) * FROM [AAC\vafscjaesct].Whatever
WHERE Id NOT IN (
   SELECT top 4 Id FROM [AAC\vafscjaesct].Whatever
   ORDER BY DataPoint, SomethingElse
)
ORDER BY DataPoint, SomethingElse

No comments:

Post a Comment