Write a query to find the top three most-watched content genres for the last month, broken down by active user segment. Use the previous calendar month and include only active users and positive watch durations.
active_segment, genre, total_watch_minutes, and genre_rank.active_segment, then genre_rank.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| active_segment | VARCHAR(30) | Business segment assigned to the user |
| is_active | BOOLEAN | Whether the user is currently active |
| Column | Type | Description |
|---|---|---|
| watch_event_idPK | INT | Unique viewing event identifier |
| user_id | INT | User who watched the content |
| content_id | INT | Content watched during the event |
| started_at | TIMESTAMP | Timestamp when viewing started |
| watch_seconds | INT | Number of seconds watched |
| Column | Type | Description |
|---|---|---|
| content_idPK | INT | Unique content identifier |
| title | VARCHAR(120) | Content title |
| genre | VARCHAR(40) | Content genre |