StreamWave tracks user activity across its app and wants a daily engagement trend. Write a SQL query to calculate the 7-day rolling average of daily active users.
A user is active on a date if they generated at least one event that day.
user_events table. Events with a NULL user_id are anonymous and do not count toward active users.0 daily active users.rolling_7_day_avg is the average of daily_active_users over the current date and the 6 calendar days before it. The first dates in the range have fewer than 6 earlier days, so average only the days available.rolling_7_day_avg to 4 decimal places.event_date, daily_active_users, and rolling_7_day_avg, ordered by event_date ascending.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event record ID |
| user_id | INT | User who generated the event; may be NULL for anonymous events |
| event_name | VARCHAR(50) | Type of user event |
| event_time | TIMESTAMP | Timestamp when the event occurred |