ROWNUM
ROWNUM is a pseudocolumn in SQL that assigns a unique, sequential number to each row in the fetched result set, starting from 1. The assignment of numbers is performed after the execution of the WHERE clause and before the ORDER BY clause, if any. It is not a physical column and is used to limit the number of rows in the output, typically for performance optimization purposes.
Example
Output
Explanation
In the SQL example given, the ROWNUM pseudocolumn is used in conjunction with the WHERE clause to limit the output to the first 5 rows retrieved from the EMPLOYEES table. The column sequence for the output is ROWNUM, EMPLOYEE_ID, FIRST_NAME, LAST_NAME.