period_start and period_end from the Sales table.Product table with the CTE or derived table on product_id.period_start and period_end range for each product.product_id, product_name, and year, and calculate the sum of average_daily_sales for each group.product_id and year.
erDiagram
Product {
int product_id PK
varchar product_name
}
Sales {
int product_id PK
date period_start
date period_end
int average_daily_sales
}
Product ||--o{ Sales : contains