ROWNUM

From Oracle FAQ
Jump to: navigation, search

ROWNUM is a pseudo-column that returns a row's position in a result set. ROWNUM is evaluated AFTER records are selected from the database and BEFORE the execution of ORDER BY clause.

The following type of queries will ALWAYS return NO DATA:

... WHERE ROWNUM > x
... WHERE ROWNUM BETWEEN x AND y
... WHERE ROWNUM IN (x, y, z, ...)

However, this will work:

... WHERE ROWNUM < x

This query will return ROWNUM values that are out of numerical order:

select ROWNUM, deptno from emp where  ROWNUM < 10
order  by deptno, ROWNUM;
Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #