Contents

Department Highest Salary

   Mar 19, 2023     0 min read

Department Highest Salary

문제

184-1.jpg
184-2.jpg
184-3.jpg

코드

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;

수행결과

184result.jpg