SQL query to find the customer_ids that bought all the products
IntuitionApproachCOUNT(DISTINCT product_key) counts the number of unique products each customer has purchased.
The subquery (SELECT COUNT(*) FROM Product) retri
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
COUNT(DISTINCT product_key) counts the number of unique products each customer has purchased.
The subquery (SELECT COUNT(*) FROM Product) retrieves the total number of unique products available in the Product table.
The HAVING clause ensures that only those customer_ids who have purchased all products are included in the result.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```mysql []
# Write your MySQL query statement below
SELECT customer_id
FROM Customer
GROUP BY customer_id
HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(*) FROM Product);
```
['MySQL']