diff --git a/Customers_who_Bought_All_Products.txt b/Customers_who_Bought_All_Products.txt new file mode 100644 index 0000000..2cc9f34 --- /dev/null +++ b/Customers_who_Bought_All_Products.txt @@ -0,0 +1,2 @@ +select customer_id from customer group by customer_id +having count(distinct product_key) = (select count(*) from product) diff --git a/Product_Sales_Analysis_III.txt b/Product_Sales_Analysis_III.txt new file mode 100644 index 0000000..0ee848c --- /dev/null +++ b/Product_Sales_Analysis_III.txt @@ -0,0 +1,2 @@ +with cte as (select product_id,year,quantity,price, rank() over(partition by product_id order by year) as rnk from sales) +select product_id, year as first_year, quantity, price from cte where rnk = 1;