Write SQL and Python, run instantly in your browser, and track your progress.
As a Senior Data Analyst at Netflix, you're working with the Product Analytics team to understand viewing patterns and device engagement for active subscribers. The team is building a dashboard to monitor user engagement quality by tracking meaningful viewing sessions across different device types.
Your task is to identify the most recent high-quality viewing session for each device used by customers with active subscriptions. A "high-quality" session is defined as a completed session where the user watched at least 10 minutes (600 seconds) of content, indicating genuine engagement rather than accidental starts or brief sampling.
For each qualifying device, you need to find the most recent session that meets the engagement threshold and provide the session ID, customer ID, device ID, when the session started, and how many seconds were watched.
| Column Name | Type |
|---|---|
| user_id | INTEGER |
As a Senior Data Analyst at Netflix, you're working with the Product Analytics team to understand viewing patterns and device engagement for active subscribers. The team is building a dashboard to monitor user engagement quality by tracking meaningful viewing sessions across different device types.
Your task is to identify the most recent high-quality viewing session for each device used by customers with active subscriptions. A "high-quality" session is defined as a completed session where the user watched at least 10 minutes (600 seconds) of content, indicating genuine engagement rather than accidental starts or brief sampling.
For each qualifying device, you need to find the most recent session that meets the engagement threshold and provide the session ID, customer ID, device ID, when the session started, and how many seconds were watched.
| Column Name | Type |
|---|---|
| user_id | INTEGER |
| TEXT |
| TEXT |
| full_name | TEXT |
| full_name | TEXT |
| country | TEXT |
| country | TEXT |
| language | TEXT |
| language | TEXT |
| created_at | TEXT |
| created_at | TEXT |
| account_status | TEXT |
| account_status | 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 |
| Column Name | Type |
|---|---|
| subscription_id | INTEGER |
| user_id | INTEGER |
| plan_id | INTEGER |
| start_date | TEXT |
| end_date | TEXT |
| status | TEXT |
| Column Name | Type |
|---|---|
| subscription_id | INTEGER |
| user_id | INTEGER |
| plan_id | INTEGER |
| start_date | TEXT |
| end_date | TEXT |
| status | TEXT |
| subscription_id | user_id | plan_id | start_date | end_date | status | auto_renew |
|---|---|---|---|---|---|---|
| 1 | 58 | 6 | 2025-07-26 | active | 1 | |
| 2 |
| subscription_id | user_id | plan_id | start_date | end_date | status | auto_renew |
|---|---|---|---|---|---|---|
| 1 | 58 | 6 | 2025-07-26 | active | 1 | |
| 2 |
| Column Name | Type |
|---|---|
| session_id | INTEGER |
| user_id | INTEGER |
| device_id | INTEGER |
| title_id | INTEGER |
| episode_id | INTEGER |
| started_at | TEXT |
| Column Name | Type |
|---|---|
| session_id | INTEGER |
| user_id | INTEGER |
| device_id | INTEGER |
| title_id | INTEGER |
| episode_id | INTEGER |
| started_at | 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 |
| session_id | user_id | device_id | started_at | watch_seconds |
|---|---|---|---|---|
| 10 | 2 | 4 | 2025-08-30T18:27:27 | 1680 |
| 409 | 49 | 94 | 2025-08-29T00:04:37 | 1620 |
| 104 | 12 | 26 | 2025-08-27T07:49:40 | 2220 |
| session_id | user_id | device_id | started_at | watch_seconds |
|---|---|---|---|---|
| 10 | 2 | 4 | 2025-08-30T18:27:27 | 1680 |
| 409 | 49 | 94 | 2025-08-29T00:04:37 | 1620 |
| 104 | 12 | 26 | 2025-08-27T07:49:40 | 2220 |
Showing first 5 of 46 rows. Latest qualifying session per device for active subscribers.
Showing first 5 of 46 rows. Latest qualifying session per device for active subscribers.
Your final output should be a result set that meets the following requirements:
1. Filtering:
subscriptions.status = 'active').playback_sessions.status = 'completed').2. Data Processing:
started_at timestamp).session_id as a tie-breaker.Your final output should be a result set that meets the following requirements:
1. Filtering:
subscriptions.status = 'active').playback_sessions.status = 'completed').2. Data Processing:
started_at timestamp).session_id as a tie-breaker.| 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 |
| auto_renew | INTEGER |
| auto_renew | INTEGER |
| 41 |
| 41 |
| 11 |
| 11 |
| 2025-03-15 |
| 2025-03-15 |
| 2025-05-29 |
| 2025-05-29 |
| canceled |
| canceled |
| 0 |
| 0 |
| 3 | 44 | 10 | 2025-06-28 | 2025-08-04 | canceled | 0 |
| 3 | 44 | 10 | 2025-06-28 | 2025-08-04 | canceled | 0 |
| 4 | 2 | 2 | 2025-02-27 | 2025-07-25 | expired | 0 |
| 4 | 2 | 2 | 2025-02-27 | 2025-07-25 | expired | 0 |
| 5 | 55 | 3 | 2025-07-10 | active | 1 |
| 5 | 55 | 3 | 2025-07-10 | active | 1 |
| ended_at | TEXT |
| ended_at | TEXT |
| watch_seconds | INTEGER |
| watch_seconds | INTEGER |
| quality | TEXT |
| quality | TEXT |
| status | TEXT |
| status | TEXT |
| 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 |
| 359 | 43 | 83 | 2025-08-25T03:00:24 | 1740 |
| 359 | 43 | 83 | 2025-08-25T03:00:24 | 1740 |
| 368 | 44 | 86 | 2025-08-20T12:38:04 | 3780 |
| 368 | 44 | 86 | 2025-08-20T12:38:04 | 3780 |
session_iduser_iddevice_idstarted_atwatch_secondssession_iduser_iddevice_idstarted_atwatch_seconds4. Ordering:
4. Ordering:
started_at in descending order (most recent sessions first).session_id in ascending order.started_at in descending order (most recent sessions first).session_id in ascending order.