HCLTech's client operations team wants to monitor transaction-volume trends for posted client transactions. Write a PostgreSQL query that returns each transaction in January 2025 with client details, a cumulative volume per client, and a moving average across the current and two preceding transactions.
LEFT JOIN so posted transactions remain visible even when no matching client record exists.status = 'posted' and dates from 2025-01-01 through 2025-01-31.running_volume partitioned by client_id, ordered by transaction_date and transaction_id.moving_avg_volume using the current transaction and up to two preceding transactions for the same client. Ignore NULL volumes using PostgreSQL aggregate behavior.| Column | Type | Description |
|---|---|---|
| client_idPK | INTEGER | Unique client identifier |
| client_name | VARCHAR(100) | Client display name |
| client_segment | VARCHAR(30) | Client business segment |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| client_id | INTEGER | References clients.client_id |
| transaction_date | DATE | Date on which the transaction was recorded |
| volume | NUMERIC(12,2) | Transaction volume |
| status | VARCHAR(20) | Transaction processing status |