Wednesday, February 6, 2008

Find Nth Record from a table

Sometimes you have to find Nth record from a table in database. There is no such inbuilt function which could return this record. There could be many ways to find the result, I wrote a query which solves the purpose.

SELECT top 1 *
FROM (SELECT top Nth * FROM dim_store) as a
ORDER BY dim_store_id desc

No comments: