Write a SQL query to calculate the rolling 3-month average of loan originations per dealership region.
Use the provided dealership and loan origination data. Include months with no originations as zeroes, and calculate the average using the current month and up to the two preceding calendar months.
region, month_start, monthly_originations, and rolling_3_month_avg.region, then month_start.| Column | Type | Description |
|---|---|---|
| dealership_idPK | INT | Unique dealership identifier |
| dealership_name | VARCHAR(100) | Dealership name |
| region | VARCHAR(50) | Dealership sales region |
| Column | Type | Description |
|---|---|---|
| origination_idPK | INT | Unique loan origination identifier |
| dealership_id | INT | Dealership associated with the loan |
| originated_at | DATE | Loan origination date |
| loan_amount | NUMERIC(12,2) | Original loan amount |