Your question is Rolling Three-Month Average Query. 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.
Teradata Vantage reporting needs a monthly sales trend for active sales regions. Write a PostgreSQL-compatible SQL query that calculates monthly sales and a rolling three-month average for each active region from January through April 2025.
| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique identifier for a sales region |
| region_name | VARCHAR(100) | Display name of the sales region |
| is_active | BOOLEAN | Whether the region is included in reporting |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| region_id | INT | Region associated with the transaction |
| sale_date | DATE | Date on which the sale occurred |
| amount | DECIMAL(12,2) | Sales amount, which may be NULL |