is a pseudo-column that is assigned an incremental, unique integer value for each row based on the order the rows were retrieved from a query. Therefore, the first row retrieved will have ROWNUM
; the second row will have ROWNUM
and so on.
value is assigned to each row before any sorting of the result set takes place. Thus, the result set is returned in the order given by the ORDER BY
clause, but the ROWNUM
values may not necessarily be in ascending order as shown in the following example: