Leetcode
[LeetCode] Department Highest Salary [MySQL]
치킨먹고싶어요
2022. 6. 17. 17:06
https://leetcode.com/problems/department-highest-salary/
Department Highest Salary - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
SELECT D.name AS Department, E.name AS Employee, E.salary
FROM Department AS D
INNER JOIN Employee AS E
ON D.id = E.departmentId
WHERE (E.salary, E.departmentID) IN (
SELECT MAX(EE.salary), EE.departmentId
FROM Employee AS EE
GROUP BY EE.departmentId
)
|
cs |