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 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