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
4 changes: 4 additions & 0 deletions CustomersWhoBoughtAllProducts.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(*) FROM Product);
3 changes: 3 additions & 0 deletions ProductSalesAnalysis3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WITH FirstYear AS (SELECT product_id, MIN(year) AS first_year FROM Sales GROUP BY product_id)
SELECT s.product_id, f.first_year, s.quantity, s.price
FROM Sales s JOIN FirstYear f ON s.product_id = f.product_id AND s.year = f.first_year;