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