Write a SQL query using window functions to calculate each Koalafi customer's rolling 30-day default rate by month.
Treat each row in customer_default_events as one customer obligation. A NULL defaulted value is not a default but remains part of the denominator. Include a customer-month when that customer has at least one event during the month.
customer_id, report_month, defaults_30_day, obligations_30_day, and rolling_30_day_default_ratecustomer_id, then report_month ascending| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique Koalafi customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| state | VARCHAR(2) | Customer state abbreviation |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique obligation event identifier |
| customer_id | INT | Customer associated with the obligation |
| event_date | DATE | Date of the obligation event |
| defaulted | BOOLEAN | Whether the obligation defaulted |
| event_type | VARCHAR(30) | Type of obligation event |