Given a table of transaction logs, write a query to calculate the total spend per user over a rolling 30-day window.
Treat each transaction date as the end of its window. Include that date and the preceding 29 calendar days. Treat NULL transaction amounts as zero.
user_id, transaction_time, transaction_id, and rolling_30_day_spend.user_id, transaction_time, and transaction_id ascending.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | User who made the transaction |
| transaction_time | TIMESTAMP | Timestamp when the transaction occurred |
| amount | NUMERIC(12,2) | Transaction amount |