Your question is Monthly Sales Aggregation by Product Category. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A retail analytics team wants to analyze monthly sales performance by product category. You are given two tables: sales records individual sales transactions, and products contains product details.
Write a SQL query to calculate the total sales amount for each product category and month.
sales and products to associate each sale with its category.YYYY-MM format).| Column | Type | Description |
|---|---|---|
| idPK | INT | Primary key for sales records |
| product_id | INT | Foreign key referencing products |
| sale_date | DATE | Date of the sale |
| amount | DECIMAL(10,2) | Sale amount |
| Column | Type | Description |
|---|---|---|
| idPK | INT | Primary key for product records |
| name | VARCHAR(255) | Name of the product |
| category | VARCHAR(255) | Category of the product |