PS/LeetCode
[LeetCode] Employees Earning More Than Their Manager
판교토끼
2020. 5. 1. 00:44
728x90
https://leetcode.com/problems/employees-earning-more-than-their-managers/
Employees Earning More Than Their Managers - 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
아마 관계형 DB를 배울 때 가장 유명한 예제가 아닐까? Employee의 Manager가 Employee에 속하는 것.
그 중에서 Salary를 비교하여 출력하는 예제였다.
# Write your MySQL query statement below
SELECT e1.Name as Employee
FROM Employee as e1
JOIN Employee as e2
ON e1.ManagerId=e2.Id and e2.Salary < e1.Salary;
JOIN을 사용했는데, 풀고 나서 Discussion을 보니 JOIN을 꼭 사용하지는 않아도 되었다.
FROM Employee as e1, Employee as e2
로 처리했어도 되더라!
728x90