Find the products and years for which each product was sold, along with the corresponding price.
Product Sales Analysis I
You are given sales records for products. Each record tells you which product was sold, in what year, and at what price.
Return a table containing the product name, the sale year, and the price for every sale record.
The result should include one row per sale record.
Input Format
The input is described by two tables:
Sales(product_id, year, quantity, price)Product(product_id, product_name)
Each row in Sales represents a product sold in a given year at a given price.
Output Format
Return the columns:
product_nameyearprice
One row should be returned for each row in Sales.
Constraints
- Each sale record belongs to exactly one product.
product_idcan be used to match sales to product names.- Keep all sale records in the output.
- Output ordering is not important unless required by the platform.
Example 1
Input
Sales +------------+------+----------+-------+ | product_id | year | quantity | price | +------------+------+----------+-------+ | 100 | 2008 | 10 | 5000 | | 100 | 2009 | 12 | 5000 | | 200 | 2011 | 15 | 9000 | +------------+------+----------+-------+ Product +------------+--------------+ | product_id | product_name | +------------+--------------+ | 100 | Nokia | | 200 | Apple | +------------+--------------+
Output
+--------------+------+-------+ | product_name | year | price | +--------------+------+-------+ | Nokia | 2008 | 5000 | | Nokia | 2009 | 5000 | | Apple | 2011 | 9000 | +--------------+------+-------+
Explanation
Match each sale record to its product name using product_id, then project the requested columns.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.