🤔 문제 분석
1) Write an SQL query to report the IDs of all the employees with missing information. The information of an employee is missing if:
- The employee's name is missing, or
- The employee's salary is missing.
2) Return the result table ordered by employee_id in ascending order.
💡 풀이
(SELECT E.employee_id
FROM Employees AS E
LEFT JOIN Salaries AS S on E.employee_id = S.employee_id
WHERE S.salary IS NULL
UNION
SELECT S.employee_id
FROM Employees AS E
RIGHT JOIN Salaries AS S on E.employee_id = S.employee_id
WHERE E.name IS NULL)
ORDER BY employee_id
'코딩테스트 > 리트코드 SQL' 카테고리의 다른 글
[리트코드/SQL] 13. Tree node (608) (0) | 2022.12.16 |
---|---|
[리트코드/SQL] 12. Rearrange Products Table (1795) (0) | 2022.12.16 |
[리트코드/SQL] 10. Patients With a Condition (1527) (0) | 2022.12.08 |
[리트코드/SQL] 9. Group Sold Products By The Date (1484) (0) | 2022.12.08 |
[리트코드/SQL] 8. Fix Names in a Table (1667) (0) | 2022.12.08 |
댓글