Skip to content

Commit 5e4c838

Browse files
committed
🟡 Solve problem 1070
1 parent 5a6ffd8 commit 5e4c838

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎sql/1070.sql

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
WITH FirstYearSales AS (
2+
SELECT
3+
product_id,
4+
MIN(year) AS first_year
5+
FROM
6+
Sales
7+
GROUP BY
8+
product_id
9+
)
10+
SELECT
11+
s.product_id,
12+
f.first_year,
13+
s.quantity,
14+
s.price
15+
FROM
16+
Sales s
17+
JOIN
18+
FirstYearSales f
19+
ON
20+
s.product_id = f.product_id
21+
AND s.year = f.first_year;

0 commit comments

Comments
 (0)