💣 using FIRST_VALUE function in Oracle
\n# 1\uFE0F\u20E3. FIRST_VALUE Code\nsql\n/* Write your PL/SQL query statement below */\nWITH sale_id_first AS (\n    SELECT \n        product_id,\n        year
\n# 1\uFE0F\u20E3. FIRST_VALUE Code\n```sql\n/* Write your PL/SQL query statement below */\nWITH sale_id_first AS (\n    SELECT \n        product_id,\n        year,\n        FIRST_VALUE(year) OVER (PARTITION BY product_id ORDER BY year) AS first_year,\n        quantity,\n        price    \n    FROM sales\n)\nSELECT \n    product_id,\n    FIRST_VALUE(year) OVER (PARTITION BY product_id ORDER BY year) AS first_year,\n    quantity,\n    price    \nFROM sale_id_first\nWHERE first_year = year;\n```\n# 2\uFE0F\u20E3. using Subqueries\n```sql\nSELECT product_id, year AS first_year, quantity, price\nFROM sales s\nWHERE year = (\n    SELECT MIN(YEAR)\n    FROM sales\n    WHERE s.product_id = product_id\n    GROUP BY product_id;\n);\n```\n\nYou Can also Look At My SDE Prep Repo [\uD83E\uDDE2 GitHub](https://github.com/Ayon-SSP/The-SDE-Prep)
['Oracle']