Search This Blog

T-SQL Query : How to retrieve only the Nth row from a table?

Method 1

SELECT * FROM t1 a
WHERE  n = (SELECT COUNT(rowid)
             FROM t1 b
            WHERE a.rowid >= b.rowid);

Method 2


SELECT * FROM (
  SELECT ENAME,ROWNUM RN FROM EMP WHERE ROWNUM < 101 )