Department Highest Salary
문제
코드
Oracle
SELECT D.NAME AS DEPARTMENT
, E.NAME AS EMPLOYEE
, E.SALARY
FROM EMPLOYEE E
INNER JOIN (
SELECT DEPARTMENTID
, MAX(SALARY) AS MAX_SALARY
FROM EMPLOYEE
GROUP BY DEPARTMENTID
) DH ON E.DEPARTMENTID = DH.DEPARTMENTID
AND E.SALARY = DH.MAX_SALARY
INNER JOIN DEPARTMENT D ON D.ID = E.DEPARTMENTID;