Write SQL and Python, run instantly in your browser, and track your progress.
You are a data analyst for the marketing team at Disney+. The team wants to reward its most engaged subscribers—those who are actively subscribed and consistently watch content in the highest available quality. They plan to send a special 'thank you' gift to this cohort.
Your task is to generate a list of these high-value users. A user qualifies if they have an active subscription and have watched at least one completed session in either 'uhd' or '4k' quality between July and December 2024.
The final report should list each qualifying user's ID, their email, their current subscription status, and the timestamp of their most recent high-quality viewing session in that date range. Sort the list by the most recent session time.
| Column Name | Type |
|---|---|
| user_id |
You are a data analyst for the marketing team at Disney+. The team wants to reward its most engaged subscribers—those who are actively subscribed and consistently watch content in the highest available quality. They plan to send a special 'thank you' gift to this cohort.
Your task is to generate a list of these high-value users. A user qualifies if they have an active subscription and have watched at least one completed session in either 'uhd' or '4k' quality between July and December 2024.
The final report should list each qualifying user's ID, their email, their current subscription status, and the timestamp of their most recent high-quality viewing session in that date range. Sort the list by the most recent session time.
| Column Name | Type |
|---|---|
| user_id |
| INTEGER |
| 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 |
| user_id | subscription_status | last_started_at | |
|---|---|---|---|
| 49 | ryan48@gmail.com | active | 2024-12-29T15:42:12 |
| 52 | asuzuki@gmail.com | active | 2024-12-23T00:05:51 |
| 15 | emily.muller@aol.com | active | 2024-12-19T07:00:13 |
| 34 | hana.davis@outlook.com | active |
| user_id | subscription_status | last_started_at | |
|---|---|---|---|
| 49 | ryan48@gmail.com | active | 2024-12-29T15:42:12 |
| 52 | asuzuki@gmail.com | active | 2024-12-23T00:05:51 |
| 15 | emily.muller@aol.com | active | 2024-12-19T07:00:13 |
| 34 | hana.davis@outlook.com | active |
Showing first 5 of 20 rows. Active subscribers with recent UHD/4K viewing activity.
Showing first 5 of 20 rows. Active subscribers with recent UHD/4K viewing activity.
Your final output should be a result set that meets the following requirements:
1. Qualifying Sessions:
status is 'completed'.quality is either 'uhd' or '4k'.started_at date is between '2024-07-01' and '2024-12-31' inclusive.started_at time for each user_id.2. Final User List:
Your final output should be a result set that meets the following requirements:
1. Qualifying Sessions:
status is 'completed'.quality is either 'uhd' or '4k'.started_at date is between '2024-07-01' and '2024-12-31' inclusive.started_at time for each user_id.2. Final User List:
| 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 |
| 2024-12-14T13:56:30 |
| 2024-12-14T13:56:30 |
| 43 | sarahpatel@proton.me | active | 2024-12-11T09:57:31 |
| 43 | sarahpatel@proton.me | active | 2024-12-11T09:57:31 |
active subscription in the subscriptions table.active subscription in the subscriptions table.3. Columns:
3. Columns:
user_idemailsubscription_status (aliased from the subscriptions.status column)last_started_at (the most recent qualifying session time)user_idemailsubscription_status (aliased from the subscriptions.status column)last_started_at (the most recent qualifying session time)4. Ordering:
4. Ordering:
last_started_at in descending order (newest first).user_id in ascending order.last_started_at in descending order (newest first).user_id in ascending order.