Skip to content
Open
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
20 changes: 20 additions & 0 deletions Completed Mock_SQL2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Customers Who Bought All Products_Solution

SELECT c.customer_id
FROM customer c
GROUP BY c.customer_id
HAVING COUNT(DISTINCT c.product_key) = (SELECT COUNT(p.product_key) FROM product p);

# Product Sales Analysis III_Solution

WITH cte AS
(
SELECT *,
RANK() OVER(PARTITION BY product_id ORDER BY year) AS 'rnk'
FROM Sales
)

SELECT product_id, year AS first_year, quantity, price
FROM cte
WHERE rnk = 1;