Your question is Running 3-Month Moving 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.
Bain & Company's analytics team wants a monthly view of revenue performance by sales region. Write a PostgreSQL query that aggregates completed sales and calculates a running three-month moving average for each region.
| Column | Type | Description |
|---|---|---|
| region_idPK | INTEGER | Unique region identifier |
| region_name | VARCHAR(50) | Sales region name |
| market | VARCHAR(50) | Market served by the region |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| region_id | INTEGER | Region associated with the transaction |
| sale_date | DATE | Transaction date |
| revenue | NUMERIC(12,2) | Transaction revenue |
| status | VARCHAR(20) | Transaction status |