Write a query utilizing a self-join and window functions to identify user engagement patterns across consecutive days on Roku.
Use daily_user_activity as the source table. Treat activity dates as consecutive when they differ by exactly one calendar day.
user_id, first_activity_date, next_activity_date, first_day_sessions, next_day_sessions, and pair_number.user_id, then first_activity_date.| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity record identifier |
| user_id | INT | Roku user identifier |
| activity_date | DATE | Calendar date of user activity |
| sessions | INT | Number of Roku sessions on the activity date |