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
14 changes: 14 additions & 0 deletions MockSQL2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# 1045 Customers Who Bought All Products

with cte as(
select c.customer_id, count(distinct c.product_key) as 'key_count' from Customer c inner join Product p on c.product_key =p.product_key group by c.customer_id
)

select distinct customer_id from cte where key_count =(select count(product_key) from product);

1070. Product Sales Analysis III

# Write your MySQL query statement below
select product_id, year as 'first_year', quantity, price from Sales where (product_id, year)
IN (select product_id, MIN(year) from Sales group by product_id);