Write a query using SQL window functions to calculate a rolling 30-day average of transaction volumes per user.
Use the transactions table. Aggregate multiple transactions occurring for the same user on the same date before calculating the rolling average. Include dates whose transaction volume is NULL, following PostgreSQL aggregate behavior.
user_id, transaction_date, daily_volume, and rolling_30_day_avguser_id, then transaction_date ascending| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | VARCHAR(20) | User associated with the transaction |
| transaction_date | DATE | Calendar date of the transaction |
| transaction_volume | NUMERIC(12,2) | Transaction volume recorded for the transaction |