Online Tutorials & Training Materials | STechies.com
Register Login

How can I get the highest salary of each department.

|| || 2

How can I get the highest salary of each department.
Stechies

Hi All,

Could you please help me to get the highest salary of each department. If multiple employees having the highest salary in the same department then I need the get oldest employee details(who joined first in the company).

Thanks in advance!


Comments

  • 30 Jul 2015 3:06 pm

    select * from (select ename,deptno,sal,hiredate,dense_rank() over(partition by deptno order by sal desc,hiredate asc) rn from emp)
    where rn=1;

  • 15 Apr 2017 11:34 pm

    SELECT DEPARTMENT_ID,MAX(SALARY) FROM EMPLOYEES

    GROUP BY DEPARTMENT_ID;