Hotstar wants to monitor how viewer engagement changes over time. Write a PostgreSQL query that calculates each user's session length and their moving average session length over the preceding 30 days, including the current session.
viewer_sessions with users to include the viewer's name.session_start.user_id and session start time.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique viewer identifier |
| user_name | VARCHAR(100) | Viewer name |
| subscription_tier | VARCHAR(20) | Hotstar subscription tier |
| Column | Type | Description |
|---|---|---|
| session_idPK | INT | Unique session identifier |
| user_id | INT | Viewer identifier |
| session_start | TIMESTAMP | Session start timestamp |
| session_end | TIMESTAMP | Session end timestamp |