Your question is SQL Window Functions Rolling 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.
AArete analysts need a smoothed view of regional sales performance. Write a PostgreSQL query that calculates a rolling average of daily completed sales for each region.
sales to stores to obtain the region.| Column | Type | Description |
|---|---|---|
| store_idPK | INT | Unique store identifier |
| store_name | VARCHAR(100) | Store name |
| region | VARCHAR(50) | Operating region |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| store_id | INT | Store associated with the sale |
| sale_date | DATE | Date on which the sale occurred |
| amount | DECIMAL(10,2) | Sale amount, possibly NULL |
| status | VARCHAR(20) | Transaction status |