From 99613bdbd92c3c4c01b87419bf590338b3789a63 Mon Sep 17 00:00:00 2001 From: Dhruv Parashar Date: Wed, 4 Jun 2025 15:23:48 -0400 Subject: [PATCH] Done Mock_SQL2 --- Customers who bought all the products.sql | 1 + Product Sales Analysis III.sql | 1 + 2 files changed, 2 insertions(+) create mode 100644 Customers who bought all the products.sql create mode 100644 Product Sales Analysis III.sql diff --git a/Customers who bought all the products.sql b/Customers who bought all the products.sql new file mode 100644 index 0000000..bf7b46d --- /dev/null +++ b/Customers who bought all the products.sql @@ -0,0 +1 @@ +SELECT customer_id FROM Customer GROUP BY customer_id HAVING COUNT(DISTINCT product_key) = (SELECT COUNT(DISTINCT product_key) AS 'num_product_key' FROM product) \ No newline at end of file diff --git a/Product Sales Analysis III.sql b/Product Sales Analysis III.sql new file mode 100644 index 0000000..18f5ef2 --- /dev/null +++ b/Product Sales Analysis III.sql @@ -0,0 +1 @@ +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