How would you write a SQL query to extract user engagement metrics over a rolling 30-day window?
Use the users and engagement_events tables. Calculate metrics for each user and event date, using the current date and the preceding 29 calendar days. Include only users with at least one recorded event.
user_id, display_name, event_date, daily_event_count, rolling_event_count, and rolling_active_daysuser_id, then event_date ascending| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| display_name | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique engagement event identifier |
| user_id | INT | User associated with the event |
| event_date | DATE | Calendar date when the event occurred |
| event_type | VARCHAR(50) | Type of engagement event |