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
16 changes: 16 additions & 0 deletions 2nd_Mock.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 1045. Customers Who Bought All Products
# Write your MySQL query statement below
SELECT customer_id
FROM Customer
GROUP BY customer_id
HAVING COUNT(distinct product_key) = (select COUNT(product_key) FROM Product);

# 1070. Product Sales Analysis III
# Write your MySQL query statement below
SELECT product_id, year AS first_year, quantity, price
FROM Sales
WHERE (product_id, year) IN (
SELECT product_id, MIN(year) as firstyear
FROM Sales
GROUP BY product_id
)