Product Sales Analysis III - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
1070. Product Sales Analysis III
Medium
30 Points
Database
Table: Sales
Write a solution to find all sales that occurred in the first year each product was sold.
Return a table with the following columns: product_id, first_year, quantity, and price.
Return the result in any order.
Examples
Example 1
+-------------+-------+
| Column Name | Type |
+-------------+-------+
| sale_id | int |
| product_id | int |
| year | int |
| quantity | int |
| price | int |
+-------------+-------+
(sale_id, year) is the primary key (combination of columns with unique values) of this table.
product_id is a foreign key (reference column) to Product table.
Each row records a sale of a product in a given year.
A product may have multiple sales entries in the same year.
Note that the per-unit price.
Table: Sales
Write a solution to find all sales that occurred in the first year each product was sold.
Return a table with the following columns: product_id, first_year, quantity, and price.
Return the result in any order.
Examples
Example 1
+-------------+-------+
| Column Name | Type |
+-------------+-------+
| sale_id | int |
| product_id | int |
| year | int |
| quantity | int |
| price | int |
+-------------+-------+
(sale_id, year) is the primary key (combination of columns with unique values) of this table.
product_id is a foreign key (reference column) to Product table.
Each row records a sale of a product in a given year.
A product may have multiple sales entries in the same year.
Note that the per-unit price.