Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions problem1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
1. We need to report the customer ids from the Customer table that bought all the products in the Product table.
2. So we first check the distinct products bought by each customer
3. We filter out the customers who dont have the count same as number of unique products
"""

with cte as
(select customer_id , count(distinct product_key) 'num'
from Customer
group by customer_id
having num = (select count(*) from Product)
)
select cte.customer_id from cte;