https://leetcode.com/problems/customers-who-never-order/
Problem
Analysis
1. Orders table을 LEFT JOIN 시킨다
2. 여기서 참조키가 아닌 것들으 NULL로 나오기 때문에 NULL인 부분을 찾는다
Solution
SELECT C.Name AS Customers
FROM Customers AS C
LEFT JOIN Orders AS O ON C.Id = O.CustomerId
WHERE O.ID IS NULL
'Algorithm > SQL' 카테고리의 다른 글
[SQL][sqlzoo] SELECT basics (0) | 2020.07.02 |
---|---|
[SQL][Leetcode] 184. Department Highest Salary (0) | 2020.06.21 |
[SQL][Leetcode] 182. Duplicate Emails (0) | 2020.06.21 |
[SQL][Leetcode] 181. Employees Earning More Than Their Managers (0) | 2020.06.21 |
[SQL][Leetcode] 177. Nth Highest Salary (0) | 2020.06.19 |