ValueMomentum's policy administration reporting feed needs a daily view of posted premium collections from active policy accounts. Write a PostgreSQL query that aggregates qualifying payments by date and calculates the cumulative collection total over time.
Requirements
- Join payments to policy accounts and include only accounts whose status is
Active.
- Include only payments with
payment_status = 'Posted'; exclude unmatched accounts and other payment statuses.
- Return one row per payment date with
daily_collected and a chronological running_total. Dates containing only NULL payment amounts should remain in the result.