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 CustomersWhoBoughtAllProducts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'''
https://leetcode.com/problems/customers-who-bought-all-products/description/
'''

SELECT customer_id
FROM Customer
GROUP BY customer_id
HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(*) FROM Product)
11 changes: 11 additions & 0 deletions ProductSalesAnalysisIII.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'''
https://leetcode.com/problems/product-sales-analysis-iii/description/
'''

SELECT product_id, year AS first_year, quantity, price
FROM Sales
WHERE (product_id, year) IN (
SELECT product_id, MIN(year)
FROM Sales
GROUP BY product_id
)