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
10 changes: 10 additions & 0 deletions Product Sales Analysis III.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- # Write your MySQL query statement below
-- select s1.product_id, s2.first_year, quantity, price
-- from Sales s1 join (
-- select product_id, min(year) as first_year from Sales
-- group by product_id
-- ) s2
-- on s1.product_id = s2.product_id and s1.year = s2.first_year

select product_id, year as first_year, quantity, price from Sales
where (product_id, year) in (select product_id, min(year) as year from Sales group by product_id)
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 @@
SELECT customer_id
FROM Customer
GROUP BY customer_id
HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(DISTINCT product_key) FROM Product)