Easy way using IN operator | MySQL
Intuition\n Describe your first thoughts on how to solve this problem. \nOur task is to find the product_id, year, quantity, and price for the first year of eve
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOur task is to find the `product_id`, `year`, `quantity`, and `price` for the first year of every product sold.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n> `IN` \u2192 This operator allows to specify multiple values\n> `MIN()` \u2192 This function returns the smallest value of the selected column\n> `GROUP BY` \u2192 This command groups rows that have the same values into summary rows, typically to perform aggregate functions on them\n\n# Code\n```\n# Write your MySQL query statement below\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']