Interview Guides
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).sales
| Column | Type | Description |
|---|---|---|
| id | 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 |
products
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key for products |
| name | VARCHAR(255) | Name of the product |
| category | VARCHAR(255) | Category of the product |