Skip to content

1070. Product Sales Analysis III 👎

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
WITH
  ProductToYear AS (
    SELECT product_id, MIN(year) AS year
    FROM Sales
    GROUP BY 1
  )
SELECT
  Sales.product_id,
  ProductToYear.year AS first_year,
  Sales.quantity,
  Sales.price
FROM Sales
INNER JOIN ProductToYear
  USING (product_id, year);