Your question is Rolling 7-Day Sales Average. 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.
BASF wants to monitor daily sales trends for products tracked in its commercial sales system. Write a PostgreSQL query that calculates a rolling 7-day average of completed sales for each product.
| Column | Type | Description |
|---|---|---|
| product_idPK | INTEGER | Unique product identifier |
| product_name | VARCHAR(100) | BASF product name |
| business_unit | VARCHAR(100) | Product business unit |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INTEGER | Unique sales transaction identifier |
| product_id | INTEGER | References products.product_id |
| sale_date | DATE | Date of the transaction |
| sale_amount | NUMERIC(12,2) | Transaction sales value |
| status | VARCHAR(20) | Transaction status |