* Problem
Write a solution to select the product id, year, quantity, and price for the first year of every product sold.
Return the resulting table in any order.
* Solution (Success)
# Write your MySQL query statement below
with ProductFirstYear as(
select product_id, min(year) as year
from Sales
Group by 1
)
select Sales.product_id,
ProductFirstYear.year as first_year,
Sales.quantity,
Sales.price
from Sales
inner join ProductFirstYear
using (product_id, year)
'Study - Problems(IT) > LeetCode - SQL' 카테고리의 다른 글
1729.Find Followers Count (0) | 2024.11.24 |
---|---|
596. Classes More Than 5 Students (2) | 2024.11.23 |
1141.User Activity for the Past 30 Days I (1) | 2024.11.21 |
2356.Number of Unique Subjects Taught by Each Teacher (0) | 2024.11.20 |
550. Game Play Analysis IV (0) | 2024.11.19 |