There really not a good solution to this issue because SQL does not imply a position relationship between rows. This query works but has some issues:
SELECT TOP 50
Customerid
FROM (
SELECT TOP 100
Customerid,
CompanyName
FROM
Customers
ORDER BY
CompanyName ASC,
customerid) AS a
ORDER BY
CompanyName DESC,
customerid
The issues are straight forward:
1 - The TOP clause is not parameterizable. You'll have to use Dynamic SQL or an ad-hoc query.
2 - In order to get the last set of rows, the derived table will have to calculate the entire table. If you're going to really use this query in a production environment, you'll have to figure out a way to reverse everything when you page past half the file.
-Mike