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
8 changes: 8 additions & 0 deletions Problem1_CustomerProduct.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Write your MySQL query statement below

select customer_id
#,count(distinct product_key) as productcount
from customer
group by customer_id
having count(distinct product_key) in (select count(product_key)
from product);
10 changes: 10 additions & 0 deletions Problem2_ProductAnalysis.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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,c.first_year,s.quantity,s.price
from Sales s
inner join cte c on s.product_id=c.product_id
where s.product_id=c.product_id and s.year=c.first_year