Sales table by product_id and selects the minimum year for each group.product_id, year (aliased as first_year), quantity, and price from the Sales table.WHERE clause in the main query to filter the results to only include rows where the combination of product_id and year matches the combination returned by the subquery.erDiagram
Sales {
int sale_id
int product_id
int year
int quantity
int price
}
Product {
int product_id
varchar product_name
}
Sales }|--|| Product : "foreign key"