Easy and Simple Solution
Please Like ❤️IntuitionWe need to find the first year in which each product was sold along with its quantity and price.Approach
Find the earliest year for each
```mysql
# Write your MySQL query statement below
SELECT product_id, year AS first_year, quantity, price
FROM Sales
WHERE (product_id, year) IN (
    SELECT product_id, MIN(year) AS year
    FROM Sales
    GROUP BY product_id
);
```

# Please Like ❤️  
![Please Like](https://media.tenor.com/heEyHbV8iaUAAAAM/puss-in-boots-shrek.gif)  

# Intuition  
We need to find the first year in which each product was sold along with its quantity and price.

# Approach  
1. **Find the earliest year** for each `product_id` using `MIN(year)` and `GROUP BY product_id`.  
2. **Retrieve relevant records** using `WHERE (product_id, year) IN (...)`, ensuring we get quantity and price for that year.  

# Complexity  
- **Time Complexity:** $$O(n)$$ – The subquery computes `MIN(year)` in $$O(n)$$, and filtering runs in $$O(n)$$.  
- **Space Complexity:** $$O(1)$$ – The query only stores results temporarily.  
['MySQL']