PwC's Halo analytics platform needs a client-level view of transaction activity for the reporting period from January 1 through February 15, 2025. Write a PostgreSQL query that aggregates daily transaction volumes, calculates a cumulative total, and computes a trailing 30-day moving average for each active client.
Requirements
- Join
clients to client_transactions and include only active clients.
- Aggregate transaction volume by client and transaction date. Treat a NULL transaction volume as zero.
- Calculate a chronological running total for each client.
- Calculate the average of recorded daily volumes from the current date and preceding 29 calendar days. Dates without transactions do not contribute rows to the average.
- Return results ordered by client ID and transaction date.