Netflix wants to identify recurring binge-watching sequences from profile viewing logs. A binge pair is two completed sessions for the same profile where the second title starts after the first session ends and within 30 minutes.
Write a PostgreSQL query to find and rank title-to-title binge patterns.
viewing_sessions to compare consecutive sessions for the same profile.| Column | Type | Description |
|---|---|---|
| session_idPK | INT | Unique viewing session identifier |
| profile_id | INT | Netflix profile identifier |
| title_id | INT | Watched title identifier |
| started_at | TIMESTAMP | Session start timestamp |
| ended_at | TIMESTAMP | Session end timestamp |
| duration_minutes | INT | Minutes watched during the session |
| completed | BOOLEAN | Whether the session was completed |
| Column | Type | Description |
|---|---|---|
| title_idPK | INT | Unique title identifier |
| title_name | VARCHAR(100) | Netflix title name |