SQL SERVER
\n# Code\n\nWITH cte AS (\n    SELECT product_id, MIN(year) AS minyear \n    FROM sales \n    GROUP BY product_id \n)\nSELECT s.product_id, s.year AS first_year
\n# Code\n```\nWITH cte AS (\n    SELECT product_id, MIN(year) AS minyear \n    FROM sales \n    GROUP BY product_id \n)\nSELECT s.product_id, s.year AS first_year, s.quantity, s.price \nFROM sales s\nINNER JOIN cte ON cte.product_id = s.product_id \n              AND s.year = cte.minyear;\n\n```
['MS SQL Server']