Write a SQL query to calculate the monthly active users (MAU) and the month-over-month retention rate for Roku streaming devices.
Use only valid playback activity from Roku devices associated with known users. Treat a user as active once per calendar month.
month_start, mau, previous_month_mau, retained_users, and retention_rate_pct.NULL when no previous-month denominator exists.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Roku account identifier |
| user_name | VARCHAR(100) | Display name for the Roku account |
| account_status | VARCHAR(20) | Current account status |
| Column | Type | Description |
|---|---|---|
| device_idPK | INT | Unique Roku streaming device identifier |
| user_id | INT | Roku account associated with the device |
| model_name | VARCHAR(80) | Roku device model |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity event identifier |
| device_id | INT | Device that generated the event |
| activity_at | TIMESTAMP | Timestamp when the activity occurred |
| event_type | VARCHAR(40) | Type of device activity event |