Many times, it is required to implement paging in SQL. Well you can find many ways to accomplish it but recently I came across to a very simple way of doind this.
Consider you want to find the records from 21-30 in order of their IDs, then you can do this using the folllowing query:
SELECT TOP 10 *
FROM (SELECT TOP 30 *
FROM tableName
ORDER BY ID)
FROM (SELECT TOP 30 *
FROM tableName
ORDER BY ID)
ORDER BY ID DESC.
Yup it is a very easy and handy way to implement paging.