2 Lines Very Easy to Understand + Explained Solution MySQL
Intuition\nUse first table (Customer) and count all from (Product) second table.\n# Approach\n1. We\'re selecting the customer_id from the Customer table.\n\n2.
# Intuition\n**Use first table (Customer) and count all from (Product) second table.**\n# Approach\n1. We\'re selecting the customer_id from the Customer table.\n\n2. The GROUP BY c.customer_id groups the results by customer ID.\n\n3. The HAVING clause filters the results to include only those customers who have purchased all the distinct products.\n\n4. COUNT(DISTINCT c.product_key) counts the distinct products bought by each customer.\n\n5. (SELECT COUNT(*) FROM Product) gets the total count of distinct products available in the Product table.\n\n\n# Code\n```\n# Write your MySQL query statement below\n\nSELECT c.customer_id FROM Customer c GROUP BY c.customer_id\nHAVING COUNT(DISTINCT c.product_key) = (SELECT COUNT(*) FROM Product);\n```
['MySQL']