Given a database schema with user actions and transaction histories, write a SQL query to calculate the rolling 7-day average of user spending for Garner health analytics.
Use completed transactions linked to spending actions. Treat dates without spending as zero and return results only for users with at least one qualifying transaction.
Output
- One row per user and spending date
- Columns:
user_id, spending_date, daily_spending, rolling_7_day_avg
- Include dates from each user's first qualifying transaction through their last
- Order by
user_id, then spending_date