#111. [LeetCode / MySQL] 1978. Employees Whose Manager Left the Company

문제

 

 

입력 코드

1. SUBQUERY

SELECT employee_id FROM Employees
WHERE salary < 30000
AND manager_id NOT IN (SELECT employee_id FROM Employees)
ORDER BY employee_id;

 

 

2. LEFT JOIN

SELECT e1.employee_id FROM Employees AS e1
LEFT JOIN Employees AS e2
ON e1.manager_id = e2.employee_id
WHERE e1.salary < 30000
AND e2.employee_id IS NULL
AND e1.manager_id IS NOT NULL
ORDER BY employee_id;

 

 

코드 설명

#SELECT #WHERE #NOT IN #ORDER BY #LEFT JOIN # JOIN #NULL #AS #ON

 

 

문제 출처

https://leetcode.com/problems/employees-whose-manager-left-the-company/description/?envType=study-plan-v2&envId=top-sql-50