MSSQLSERVER 97% faster and easier to understand
select\nproduct_id,year as first_year,quantity,price\nfrom\n(select\nproduct_id,year,quantity,price,\nrank() over (partition by product_id order by year) as yea
select\nproduct_id,year as first_year,quantity,price\nfrom\n(select\nproduct_id,year,quantity,price,\nrank() over (partition by product_id order by year) as year_row\nfrom\nsales)a where a.year_row = 1
[]