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
2 changes: 2 additions & 0 deletions Customers Who Bought All Products
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

select distinct(c.customer_id) from customer c right join product p on c.product_key=p.product_key group by c.customer_id having count( distinct p.product_key) = (select count(distinct(product_key)) from product)
16 changes: 16 additions & 0 deletions Sales Analysis III
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
WITH cte AS (
SELECT
product_id,
year,
quantity,
price,
RANK() OVER (PARTITION BY product_id ORDER BY year ASC) AS rnk
FROM Sales
)
SELECT
product_id,
year AS first_year,
quantity,
price
FROM cte
WHERE rnk = 1;