Customers Who Bought All Products
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Customers Who Bought All Products
You have two tables: Customer and Product. Each row in Customer records a purchase of a product by a customer. Write a SQL query to report the IDs of all customers who have bought all the products listed in the Product table. Return the result in any order.
Examples
Example 1
Customers 1 and 3 both purchased products 5 and 6 - all available products. Customer 2 only bought product 6.
Approach hint
Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
query.sql