In an Oracle database, what is the difference between ROWNUM and ROW_NUMBER?
What is the difference between ROWNUM and ROW_NUMBER ? ROWNUM is a "pseudocolumn" that assigns a number to each row returned by a query: SQL> select rownum, ename, deptno 2 from emp; ROWNUM ENAME DEPTNO ---------- ---------- ---------- 1 SMITH 99 2 ALLEN 30 3 WARD 30 4 JONES 20 5 MARTIN 30 6 BLAKE 30 7 CLARK 10 8 SCOTT 20 9 KING 10 10 TURNER 30 11 FORD 20 12 MILLER 10 ROW_NUMBER is an analytic function that assigns a number to each row according to its ordering within a group of rows: SQL> select ename, deptno, row_number() over (partition by deptno order by ename) rn 2 from emp; ENAME DEPTNO