diff --git a/Problem1.sql b/Problem1.sql new file mode 100644 index 0000000..56856c8 --- /dev/null +++ b/Problem1.sql @@ -0,0 +1,3 @@ +WITH CTE AS (SELECT *, DENSE_RANK() +OVER(PARTITION BY product_id ORDER BY year) as 'first_year' from sales ) +Select product_id, year as 'first_year', quantity, price from CTE where first_year = 1 \ No newline at end of file diff --git a/Problem2.sql b/Problem2.sql new file mode 100644 index 0000000..187a2e8 --- /dev/null +++ b/Problem2.sql @@ -0,0 +1,2 @@ +SELECT customer_id from customer group by customer_id +having COUNT(Distinct product_key) = (Select COUNT(distinct product_key) from product) \ No newline at end of file