Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions customers-who-bought-all-products.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write your MySQL query statement below
select customer_id
From (select customer_id , count(distinct(product_key)) as cnt
from customer group by customer_id) as s where cnt = (select count(*) from Product);
8 changes: 8 additions & 0 deletions product-sales-analysis-iii.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Write your MySQL query statement below
With CTE as (
select product_id, min(year) as 'first_year' from Sales group by product_id
)
select s.product_id, s.year as 'first_year', s.quantity, s.price from Sales s
join cte on cte.first_year=s.year and cte.product_id=s.product_id;