A Simple and Easy Solution using GROUP BY, DISTINCT and COUNT() | BEGINNER LEVEL 👍
Explanation\n\nWe use group by customer_id to disinguish each customer_id and check the number of distinct products they have bought.\n\nSELECT customer_id FROM
# Explanation\n\nWe use group by customer_id to disinguish each customer_id and check the number of distinct products they have bought.\n\nSELECT customer_id FROM Customer GROUP BY customer_id HAVING COUNT(DISTINCT product_key)\n\nAnd then we check if this count matches with the count of available products in the product table.\n\nSELECT customer_id FROM Customer GROUP BY customer_id HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(*) FROM Product)\n\nIF the count matches, then it is believed that customer has in fact purchased all the available products \uD83D\uDC4D.\n\n\n# Code\n```\n# Write your MySQL query statement below\n\nSELECT customer_id FROM Customer GROUP BY customer_id HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(*) FROM Product)\n```
['MySQL']