Given a SQL database of insurance policies and claims, write a query using window functions to calculate the cumulative loss ratio per region over time.
Use earned premium as the denominator and incurred claim amounts as the numerator. Include months represented by either policies or claims, and treat missing monetary values as zero.
region, month, earned_premium, incurred_claims, cumulative_earned_premium, cumulative_incurred_claims, and cumulative_loss_ratio.region, then month ascending.| Column | Type | Description |
|---|---|---|
| policy_idPK | INT | Unique policy identifier |
| region | VARCHAR(50) | Insurance region |
| earned_month | DATE | Month represented by the earned premium record |
| earned_premium | DECIMAL(12,2) | Premium earned during the month |
| Column | Type | Description |
|---|---|---|
| claim_idPK | INT | Unique claim identifier |
| policy_id | INT | Policy associated with the claim |
| claim_date | DATE | Date the claim was reported |
| incurred_amount | DECIMAL(12,2) | Incurred claim amount |