홍동이의 성장일기
[LeetCode] 183. Customers Who Never Order 본문
Write a solution to find all customers who never order anything.
Return the result table in any order.
The result format is in the following example.
-- 내가 제출한 답
SELECT name as Customers
FROM Customers c LEFT JOIN Orders o
ON c.id = o.customerId
where o.customerId IS NULL
--1위 solutions
SELECT name as Customers
FROM Customers c
WHERE c.id NOT IN (SELECT customerID FROM Orders)
💡 개념정리
다중행 서브쿼리를 사용하면 더욱 간단하게 해결할 수 있었던 문제였다.
서브쿼리에 익숙해지기!
📍본 내용은 데이터리안 'SQL 데이터 분석 캠프 실전반' 을 수강하며 작성한 내용입니다.
728x90
'Tool > SQL 코딩테스트 풀이' 카테고리의 다른 글
[LeetCode] 184. Department Highest Salary (0) | 2023.08.12 |
---|---|
[LeetCode] 181. Employees Earning More Than Their Managers (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 |
[HackerRank] Type of Triangle (0) | 2023.04.17 |
Comments