Interview Guides

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 considered active on a given date if they generated at least one event that day. Use the event log and return one row per calendar date present in the data.
user_events table.user_id is NULL; those rows should not count toward active users.event_date, daily_active_users, and rolling_7_day_avg.event_date ascending.user_events| column | type | description |
|---|---|---|
| event_id | INT | Unique event record ID |
| user_id | INT | User who generated the event; can be NULL |
| event_name | VARCHAR(50) | Type of event |
| event_time | TIMESTAMP | Timestamp of the event |