Write a SQL query utilizing window functions to calculate the running total of premium payments grouped by policy type and month for Prudential Ins Co Of America In.
Use the policies and premium_payments tables. Include matched policy payments, treat NULL premium amounts as zero, and exclude payments without a matching policy.
policy_type, payment_month, monthly_premium, and running_total.policy_type, then payment_month ascending.| Column | Type | Description |
|---|---|---|
| policy_idPK | INT | Unique policy identifier |
| policy_type | VARCHAR(50) | Type of insurance policy |
| policyholder_name | VARCHAR(100) | Name of the policyholder |
| Column | Type | Description |
|---|---|---|
| payment_idPK | INT | Unique payment identifier |
| policy_id | INT | Policy associated with the payment |
| payment_date | DATE | Date the premium payment was recorded |
| premium_amount | NUMERIC(12,2) | Premium payment amount |