Image Alt photo_exhibition

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.

Image Alt photo_exhibition

이 문제는 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)