728x90
https://leetcode.com/problems/customers-who-never-order/
Customers Who Never Order - LeetCode
Can you solve this real interview question? Customers Who Never Order - Table: Customers +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | +-------------+---------+ In SQL, id is the primary key colu
leetcode.com
문제
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 outer join Orders o
on c.id = o.customerId
where o.id is null
고객테이블과 주문 테이블을 합치고 (이떄 주문수가 없는테이블을 원하므로 leftjoin을 사용후
오더 테이블의 id가 null인 이름만 찾아준다
728x90
'문제풀이 > SQL' 카테고리의 다른 글
184. Department Highest Salary (0) | 2023.08.20 |
---|---|
181. Employees Earning More Than Their Managers (0) | 2023.08.20 |
LeetCode / Reformat Department Table (0) | 2023.08.13 |
String, Date 조건에 부합하는 중고거래 상태 조회하기 (0) | 2023.03.18 |
String, Date 조회수가 가장 많은 중고거래 게시판의 첨부파일 조회하기 (0) | 2023.03.18 |
댓글