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!

SQL: Top 3 salaried person of each department

699462Sep 23 2009 — edited Sep 24 2009
Hi All,

I want to find out top 3 salary holder of each department from employees table. if i fire the query below, then only top 3 salaried employees among all the departments are fetched; not 3 top earner of each department.
select rownum as rank, last_name, department_id, salary 
from (select last_name, department_id, salary from employees
order by salary desc)
where rownum <= 3
if any department has one/two employees then only one /two rows should be fetched. in this case what should be the SQL.

Regards,

Shariful
This post has been answered by Frank Kulash on Sep 23 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 22 2009
Added on Sep 23 2009
14 comments
31,153 views