홍동이의 성장일기
[LeetCode] 181. Employees Earning More Than Their Managers 본문
Write an SQL query to find the employees who earn more than their managers.
Return the result table in any order.
The query result format is in the following example.
SELECT e1.name as Employee
FROM employee e1 INNER JOIN employee e2
ON e1.managerId = e2.id
WHERE e1.salary > e2.salary
💡 개념정리
셀프조인(Self Join)
위 문제에서는 e1를 직원, e2를 매니저 테이블로 간주하여 셀프조인을 해주었다.
셀프조인은 연습을 더 많이 해봐야할 것 같다.
📍본 내용은 데이터리안 'SQL 데이터 분석 캠프 실전반' 을 수강하며 작성한 내용입니다.
728x90
'Tool > SQL 코딩테스트 풀이' 카테고리의 다른 글
[LeetCode] 262. Trips and Users (0) | 2023.08.14 |
---|---|
[LeetCode] 184. Department Highest Salary (0) | 2023.08.12 |
[LeetCode] 183. Customers Who Never Order (0) | 2023.08.12 |
[LeetCode] 1179. Reformat Department Table (0) | 2023.08.12 |
[LeetCode] 602. Friend Requests II: Who Has the Most Friends (0) | 2023.04.17 |
Comments