Write SQL and Python, run instantly in your browser, and track your progress.
You are a Customer Support Analyst at Netflix. The team wants to review heavy viewing behavior for recent periods to understand engagement patterns. For members with active accounts, your task is to return their three longest completed sessions within the last 120 days. Include the member identifier, session identifier, start time, viewing duration (seconds), and a rank (1 = longest). Sort by the smallest member identifier; within each member, longest first and break ties by the smallest session identifier.
| Column Name | Type |
|---|---|
| session_id | INTEGER |
| user_id | INTEGER |
| device_id | INTEGER |
You are a Customer Support Analyst at Netflix. The team wants to review heavy viewing behavior for recent periods to understand engagement patterns. For members with active accounts, your task is to return their three longest completed sessions within the last 120 days. Include the member identifier, session identifier, start time, viewing duration (seconds), and a rank (1 = longest). Sort by the smallest member identifier; within each member, longest first and break ties by the smallest session identifier.
| Column Name | Type |
|---|---|
| session_id | INTEGER |
| user_id | INTEGER |
| device_id | INTEGER |
| title_id | INTEGER |
| title_id | INTEGER |
| episode_id | INTEGER |
| episode_id | INTEGER |
| started_at | TEXT |
| started_at | TEXT |
| ended_at | TEXT |
| ended_at | TEXT |
| watch_seconds | INTEGER |
| watch_seconds | INTEGER |
| quality | TEXT |
| quality | TEXT |
| status | TEXT |
| status | TEXT |
| session_id | user_id | device_id | title_id | episode_id | started_at | ended_at | watch_seconds | quality | status |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 205 |
| session_id | user_id | device_id | title_id | episode_id | started_at | ended_at | watch_seconds | quality | status |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 205 |
| Column Name | Type |
|---|---|
| user_id | INTEGER |
| TEXT | |
| full_name | TEXT |
| country | TEXT |
| language | TEXT |
| created_at | TEXT |
| Column Name | Type |
|---|---|
| user_id | INTEGER |
| TEXT | |
| full_name | TEXT |
| country | TEXT |
| language | TEXT |
| created_at | TEXT |
| user_id | full_name | country | language | created_at | account_status | |
|---|---|---|---|---|---|---|
| 1 | andrewbrown@icloud.com | Andrew Brown | CA | en | 2025-06-14 | active |
| 2 |
| user_id | full_name | country | language | created_at | account_status | |
|---|---|---|---|---|---|---|
| 1 | andrewbrown@icloud.com | Andrew Brown | CA | en | 2025-06-14 | active |
| 2 |
| user_id | session_id | started_at | watch_seconds | session_rank |
|---|---|---|---|---|
| 1 | 6 | 2025-05-20T02:41:57 | 7500 | 1 |
| 1 | 8 | 2025-06-28T17:27:04 | 5280 | 2 |
| 1 | 5 | 2025-06-03T16:11:40 | 1380 | 3 |
| user_id | session_id | started_at | watch_seconds | session_rank |
|---|---|---|---|---|
| 1 | 6 | 2025-05-20T02:41:57 | 7500 | 1 |
| 1 | 8 | 2025-06-28T17:27:04 | 5280 | 2 |
| 1 | 5 | 2025-06-03T16:11:40 | 1380 | 3 |
Showing first 5 of 455 rows. Top 3 longest sessions per user (last 120 days).
Showing first 5 of 455 rows. Top 3 longest sessions per user (last 120 days).
| 2025-06-26T05:44:01 |
| 2025-06-26T05:44:01 |
| 2025-06-26T06:33:55 |
| 2025-06-26T06:33:55 |
| 2700 |
| 2700 |
| hd |
| hd |
| completed |
| completed |
| 2 | 1 | 1 | 139 | 2025-04-04T23:41:32 | 2025-04-04T23:57:22 | 678 | 4k | abandoned |
| 2 | 1 | 1 | 139 | 2025-04-04T23:41:32 | 2025-04-04T23:57:22 | 678 | 4k | abandoned |
| 3 | 1 | 2 | 328 | 2024-12-04T15:21:55 | 2024-12-04T16:07:01 | 2460 | 4k | completed |
| 3 | 1 | 2 | 328 | 2024-12-04T15:21:55 | 2024-12-04T16:07:01 | 2460 | 4k | completed |
| 4 | 1 | 1 | 38 | 2025-02-15T10:35:42 | 2025-02-15T11:40:58 | 3626 | uhd | abandoned |
| 4 | 1 | 1 | 38 | 2025-02-15T10:35:42 | 2025-02-15T11:40:58 | 3626 | uhd | abandoned |
| 5 | 1 | 1 | 5 | 2025-06-15T03:24:01 | 2025-06-15T03:33:03 | 293 | sd | error |
| 5 | 1 | 1 | 5 | 2025-06-15T03:24:01 | 2025-06-15T03:33:03 | 293 | sd | error |
| account_status | TEXT |
| account_status | TEXT |
| anthony.dubois@mail.com |
| anthony.dubois@mail.com |
| Anthony Dubois |
| Anthony Dubois |
| US |
| US |
| en |
| en |
| 2024-11-24 |
| 2024-11-24 |
| active |
| active |
| 3 | david92@hotmail.com | David Wagner | ES | es | 2024-11-25 | active |
| 3 | david92@hotmail.com | David Wagner | ES | es | 2024-11-25 | active |
| 4 | valentina_smith@outlook.com | Valentina Smith | DE | de | 2024-12-17 | active |
| 4 | valentina_smith@outlook.com | Valentina Smith | DE | de | 2024-12-17 | active |
| 5 | omar.wilson@yahoo.com | Omar Wilson | FR | fr | 2025-07-27 | active |
| 5 | omar.wilson@yahoo.com | Omar Wilson | FR | fr | 2025-07-27 | active |
| 3 | 32 | 2025-07-23T16:16:06 | 3540 | 1 |
| 3 | 32 | 2025-07-23T16:16:06 | 3540 | 1 |
| 3 | 35 | 2025-05-03T19:53:52 | 3000 | 2 |
| 3 | 35 | 2025-05-03T19:53:52 | 3000 | 2 |