Netflix’s recommendation engine often looks at "Co-occurrence"—the frequency with which two different shows are watched by the same user. This helps in building a content graph for recommendations.
Your task is to find the top pairs of shows that have been watched by the same users.
| view_id(INTEGER) | user_id(INTEGER) | show_id(INTEGER) | view_date(DATE) |
|---|---|---|---|
| 1 | 1 | 101 | 2026-01-01 |
| 2 | 1 | 102 | 2026-01-02 |
| 3 | 2 | 101 | 2026-01-05 |
| 4 | 2 | 102 | 2026-01-06 |
| 5 | 3 | 101 | 2026-01-10 |
| 6 | 3 | 103 | 2026-01-11 |
| 7 | 4 | 101 | 2026-01-12 |
| 8 | 4 | 102 | 2026-01-13 |
| show_id(INTEGER) | title(VARCHAR) |
|---|---|
| 101 | Stranger Things |
| 102 | The Crown |
| 103 | The Witcher |
| user_id(INTEGER) | country(VARCHAR) |
|---|---|
| 1 | USA |
| show_title_1(VARCHAR) | show_title_2(VARCHAR) | co_watch_count(INTEGER) |
|---|---|---|
| Stranger Things | The Crown | 3 |