Find the products and years for which each product was sold, along with the corresponding price.
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.
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.
Return the columns:
product_nameyearpriceOne row should be returned for each row in Sales.
product_id can be used to match sales to product names.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
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.