From 27010dc3cd00992591af63549a16ea53b10c03e2 Mon Sep 17 00:00:00 2001 From: sagar1023 Date: Thu, 12 Jun 2025 02:40:10 -0400 Subject: [PATCH] Done Mock SQL 2 --- MockSQL2.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 MockSQL2.sql diff --git a/MockSQL2.sql b/MockSQL2.sql new file mode 100644 index 0000000..9b85ae1 --- /dev/null +++ b/MockSQL2.sql @@ -0,0 +1,14 @@ + +# 1045 Customers Who Bought All Products + +with cte as( +select c.customer_id, count(distinct c.product_key) as 'key_count' from Customer c inner join Product p on c.product_key =p.product_key group by c.customer_id +) + +select distinct customer_id from cte where key_count =(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) from Sales group by product_id); \ No newline at end of file