MySQL solution MIN(year) group by product_id
Intuition\n Describe your first thoughts on how to solve this problem. \nselect year of first sold of each prodcut in Sales table\nuse then to filter Sales tabl
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nselect year of first sold of each prodcut in Sales table\nuse then to filter Sales table\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# Write your MySQL query statement below\n\n# product id, year, quantity, and price \n# first year of every product sold\n\n\nSELECT product_id, year AS first_year, quantity, price\nFROM Sales\nWHERE (product_id, year) in (\n    SELECT product_id, MIN(year) \n    FROM Sales\n    GROUP BY product_id\n)\n```
['MySQL']