Interview Guides

StreamWave wants to measure how each user’s activity changes from one week to the next. Write a SQL query to compare weekly behavior using window functions.
user_id and week_start.users| column | type | description |
|---|---|---|
| user_id | INT | Primary key for each user |
| user_name | VARCHAR(100) | User name |
| signup_date | DATE | Date the user signed up |
| plan_type | VARCHAR(20) | Subscription plan |
watch_sessions| column | type | description |
|---|---|---|
| session_id | INT | Primary key for each session |
| user_id | INT | User who created the session |
| session_start | TIMESTAMP | Session start time |
| minutes_watched | INT | Minutes watched in the session |
| device_type | VARCHAR(20) | Device used for the session |