Difference When Using ROWNUM

I am looking for an Oracle swap request on the network, and most of them told me to execute the request twice:

SELECT * 
  FROM (SELECT t.*, ROWNUM rn 
          FROM tableName t 
         WHERE ROWNUM < 200) 
 WHERE rn > 100

Just wondering if I can type it like:

SELECT *, ROWNUM rn 
  FROM tableName t 
 WHERE ROWNUN BETWEEN 100 AND 200

It seems the second one works. Are there any (working) differences between the two queries?

+5
source share
2 answers

, , ROWNUM. , , , rownum, . BETWEEN , , , , , . , , .

, , : http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns009.htm

SELECT * FROM employees
    WHERE ROWNUM > 1;

" ROWNUM 1 . , , , ROWNUM 1 . , ."

+4

ROWNUM:

SELECT x.* 
  FROM (SELECT t.*, 
               ROWNUM rn 
          FROM tableName t) AS x
 WHERE x.rn > 100
   AND x.rn < 200

BETWEEN , .

ROWNUM . ( Oracle.

+4

All Articles