From 2e8603a127c81d1ab6d4a903e26290b0f8b581a5 Mon Sep 17 00:00:00 2001 From: Divyam Sobti Date: Wed, 1 Jan 2025 15:36:13 -0800 Subject: [PATCH 1/2] Create 1.sql --- 1.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 1.sql diff --git a/1.sql b/1.sql new file mode 100644 index 0000000..3729121 --- /dev/null +++ b/1.sql @@ -0,0 +1,8 @@ +select customer_id +from Customer +group by customer_id +having count(distinct product_key) = +( + select count(product_key) + from product +) \ No newline at end of file From 17728c02fe661cd2ea265f9e0d9ebc46ea90a2cf Mon Sep 17 00:00:00 2001 From: Divyam Sobti Date: Wed, 1 Jan 2025 15:36:15 -0800 Subject: [PATCH 2/2] Create 2.sql --- 2.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 2.sql diff --git a/2.sql b/2.sql new file mode 100644 index 0000000..0c993a0 --- /dev/null +++ b/2.sql @@ -0,0 +1,9 @@ +# Write your MySQL query statement below +with cte as ( + select distinct product_id as p, min(year) as first_year + from sales + group by product_id +) +select product_id, first_year, quantity,price from sales +join cte +on product_id= p and year = first_year \ No newline at end of file