Write SQL and Python, run instantly in your browser, and track your progress.
You are a product analyst at YouTube. The engineering team is investing heavily in optimizing the delivery of high-bitrate content (UHD, 4K). To measure the success of this investment, they want to understand user engagement with these premium formats.
Your task is to identify all viewing sessions that meet a specific set of criteria: they must be for high-quality streams ('uhd' or '4k'), have a total watch time of at least one hour (3600 seconds), and must have been watched to completion.
Please query the playback_sessions table to generate this list, sorting it to show the longest watch times first.
| Column Name | Type |
|---|---|
| session_id | INTEGER |
| user_id |
You are a product analyst at YouTube. The engineering team is investing heavily in optimizing the delivery of high-bitrate content (UHD, 4K). To measure the success of this investment, they want to understand user engagement with these premium formats.
Your task is to identify all viewing sessions that meet a specific set of criteria: they must be for high-quality streams ('uhd' or '4k'), have a total watch time of at least one hour (3600 seconds), and must have been watched to completion.
Please query the playback_sessions table to generate this list, sorting it to show the longest watch times first.
| Column Name | Type |
|---|---|
| session_id | INTEGER |
| user_id |
| INTEGER |
| INTEGER |
| device_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 |
| session_id | user_id | device_id | watch_seconds | quality | status |
|---|---|---|---|---|---|
| 474 | 57 | 109 | 10560 | uhd | completed |
| 478 | 58 | 111 | 10560 | uhd | completed |
| 325 | 39 |
| session_id | user_id | device_id | watch_seconds | quality | status |
|---|---|---|---|---|---|
| 474 | 57 | 109 | 10560 | uhd | completed |
| 478 | 58 | 111 | 10560 | uhd | completed |
| 325 | 39 |
Showing first 5 of 68 rows. Long completed sessions (1+ hour) in UHD/4K quality.
Showing first 5 of 68 rows. Long completed sessions (1+ hour) in UHD/4K quality.
Your final output should be a result set that meets the following requirements:
1. Filtering:
status of 'completed'.watch_seconds is greater than or equal to 3600.quality is either 'uhd' or '4k'.2. Columns:
session_iduser_idYour final output should be a result set that meets the following requirements:
1. Filtering:
status of 'completed'.watch_seconds is greater than or equal to 3600.quality is either 'uhd' or '4k'.2. Columns:
session_iduser_id| 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 |
| 73 |
| 73 |
| 10200 |
| 10200 |
| uhd |
| uhd |
| completed |
| completed |
| 462 | 55 | 105 | 10200 | uhd | completed |
| 462 | 55 | 105 | 10200 | uhd | completed |
| 422 | 51 | 99 | 9900 | 4k | completed |
| 422 | 51 | 99 | 9900 | 4k | completed |
device_iddevice_idwatch_secondswatch_secondsqualityqualitystatusstatus3. Ordering:
3. Ordering:
watch_seconds in descending order (longest first).session_id in ascending order.watch_seconds in descending order (longest first).session_id in ascending order.