Performing Top-N Analysis
An Oracle University Material in Sql Says
The high-level structure of a Top-N analysis query is:
SELECT [column_list], ROWNUM
FROM (SELECT [column_list]
FROM table
ORDER BY Top-N_column)
WHERE ROWNUM <= N;
For example to display the top three earner names and salaries from the EMPLOYEES table:
SELECT ROWNUM as RANK, last_name, salary
FROM (SELECT last_name,salary FROM employees
ORDER BY salary DESC)
WHERE ROWNUM <= 3;
--------------------------------------------------
My question is
If, instead of this query, I write
1)
SELECT ROWNUM as RANK, last_name, salary
FROM employees
WHERE ROWNUM <= 3
ORDER BY salary DESC
or
2)
SELECT ROWNUM as RANK, last_name, salary
FROM ( SELECT last_name,salary
FROM employees
WHERE ROWNUM <= 3
ORDER BY salary DESC
)
is any difference?
The results in schema hr are the same.............
Thank you