Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Work around of Rank() Over Function

671253Nov 19 2008 — edited Dec 4 2008
Hi Gurus,

I want to find the top three earners in each department.

Now, I can do that using a Rank() Over function. The query is:


SELECT A.*
FROM (SELECT EMPID, DEPTID, SAL, RANK() OVER (PARTITION BY DEPTID ORDER BY SAL DESC) AS RANK
FROM EMP
) AS A
WHERE RANK = 1

Is there any other work around for this.?? Can we achieve the same thing using co-related subqueries or so?? If so, then please guide in the same.

Regards,
Amit

Edited by: user10624622 on Nov 19, 2008 1:03 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2009
Added on Nov 19 2008
23 comments
1,179 views