Hi so I have done it using different method WITH car_data AS ( SELECT company_name, year, LAG(count(product_name)) OVER (PARTITION BY company_name ORDER BY year) AS prev_year_count, count(product_name) AS curr_year_count FROM car_launches GROUP BY company_name, year ) SELECT company_name, curr_year_count - prev_year_count AS net_product FROM car_data WHERE prev_year_count IS NOT NULL;
I am the first one giving thumbs up 😊 Thanks for your videos! They have helped me to improve my SQL skills!
You must have notifications on to be this early!
@@frederikmullersir pl explain this with sub query or another method. Please
Hi so I have done it using different method
WITH car_data AS (
SELECT
company_name,
year,
LAG(count(product_name)) OVER (PARTITION BY company_name ORDER BY year) AS prev_year_count,
count(product_name) AS curr_year_count
FROM
car_launches
GROUP BY
company_name, year
)
SELECT
company_name,
curr_year_count - prev_year_count AS net_product
FROM
car_data
WHERE
prev_year_count IS NOT NULL;
Thanks Frederik, you are amazing.
3rd
😂😂😂
2nd like is mine 😂❤
Thanks for sharing
Thanks for watching