Interview Guides

Facebook wants to monitor short-term engagement trends by tracking the 7-day rolling average of daily active users (DAU). Write a SQL query to calculate this metric from app activity logs.
activity_date, daily_active_users, and rolling_7d_avg_dau.activity_date ascending.facebook_activity| Column | Type | Description |
|---|---|---|
| event_id | INT | Unique event identifier |
| user_id | INT | Facebook user who generated the event |
| event_time | TIMESTAMP | Timestamp of the activity event |
| event_name | VARCHAR(50) | Type of activity event |
| device_type | VARCHAR(20) | Device used for the event |