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
13 changes: 13 additions & 0 deletions problem1-1045-customer-who-bought-all-products.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with customer_product_purchase as (
select
customer_id,
count(distinct product_key) as cnt
from
customer
group by customer_id
)

select customer_id
from
customer_product_purchase
where cnt = (select count(product_key) from product)
21 changes: 21 additions & 0 deletions problem2-1070-Product-Sales-Analysis-III.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
with product_sale_year as (
select
product_id,
year as first_year,
quantity,
price,
dense_rank() over (
partition by product_id
order by year
) as rnk
from
sales
)

select
product_id,
first_year,
quantity,
price
from product_sale_year
where rnk = 1