When is ROWNUM evaluated?

November 5th, 2008 Posted in Oracle Tip

I had someone ask me today when is ROWNUM evaluated?  Is it before the WHERE clause?  How about before or after the GROUP BY clause?  The answer is pretty simple.

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 any sorting takes place.   So ROWNUM is evalated BEFORE an ORDER BY and BEFORE a GROUP BY.

Tags:

Leave a Reply