Home » SQL & PL/SQL » SQL & PL/SQL » More Efficient Top N (Oracle 9i)
More Efficient Top N [message #327988] Wed, 18 June 2008 09:27 Go to next message
CadenceQA
Messages: 1
Registered: June 2008
Junior Member
Hello,
I wanted to confirm that there wasn't a more efficient way to rank and filter on the top X elements besides using the SQL below without adding a column in the table that contains the ranking.

SELECT *
FROM
(SELECT empno, ename, orig_salary,
DENSE_RANK() OVER(ORDER BY orig_salary desc) toprank
FROM employee)
WHERE toprank <= 5


Thanks.
Re: More Efficient Top N [message #327991 is a reply to message #327988] Wed, 18 June 2008 09:40 Go to previous message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Check this link.

http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html

Regards

Raj
Previous Topic: Sub Query Assistance
Next Topic: outer join problem
Goto Forum:
  


Current Time: Sun Dec 04 16:27:15 CST 2016

Total time taken to generate the page: 0.09007 seconds