1045. Customers Who Bought All Products
Write a solution to report the customer ids from the Customer
table that bought all the products in the Product
table.
Return the result table in any order.
The result format is in the following example.
이 문제는 Product
테이블에 있는 product_key
의 전체 개수와 customer_id
를 GROUP BY로 묶은 Customer
테이블에 있는 product_key
의 개수가 일치하면 된다.
SELECT customer_id
FROM Customer
GROUP BY customer_id
HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(*) FROM Product)