[SQL 문제 풀이] Customers Who Bought All Products (모든 제품을 구매한 고객)

Stupefyee's avatar
Jun 16, 2025
[SQL 문제 풀이] Customers Who Bought All Products (모든 제품을 구매한 고객)
notion image
고객 테이블에서 모든 제품을 구매한 고객 ID를 보고하는 솔루션을 작성하세요. 결과 테이블을 순서에 상관없이 반환하세요.
 

내가 작성한 쿼리

MySQL, Oracle

SELECT customer_id FROM Customer GROUP BY customer_id HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(*) FROM Product);
Share article

stupefyee