I am trying to fetch a range of rows in Oracle, but I am only able to fetch from the first row to a row number N.
I cannot do it in case i want to fetch a range in-between the table such as row no. 2 to 5
Lets consider EMP table below that is seen in the sample user SCOTT
Case 1: Fetch a range of rows from 1 to 5, I get the following
select EMPNO, ENAME from (select EMPNO,ENAME from EMP ORDER BY EMPNO) WHERE ROWNUM BETWEEN 1 AND 5
Case 2: Now lets try and fetch 3 rows between 2 and 5.
select EMPNO, ENAME from (select EMPNO,ENAME from EMP ORDER BY EMPNO) WHERE ROWNUM BETWEEN 2 AND 5
This gives me an empty Resultset. Why is that? What do I need to change so that I can get a range of rows from somewhere in between the table?