- ********************************************************************************************************************************************
- ************************************************************
Table: video_stream
Online movie streaming logs.
col_name | col_type ----------------------+-------------------------- stream_id | bigint stream_dt | date device_id | integer device_category | varchar(20) -- 'fire tv', 'apple tv', 'samsung tv', 'google tv', 'roku' customer_id | bigint minutes_streamed | integer buffer_count | integer -- number of seconds before the video start playing customer_country | varchar(20) -- US, UK, AU
Sample results
customer_country ------------------ US (1 row)
Solution postgres
SELECT customer_country
FROM video_stream
WHERE stream_dt >= '2021-08-01'
AND stream_dt <= '2021-08-07'
GROUP BY customer_country
ORDER BY COUNT(stream_id) DESC
LIMIT 1;
Explanation
This query selects the customer country from a table called "video_stream" for the time period between August 1st and August 7th, 2021. It then groups the results by customer country and orders them in descending order based on the count of stream ID. Finally, it limits the output to the top result (i.e., the country with the highest number of stream IDs during the specified time period).
In simpler terms, the query is trying to find the country that had the most video streams during the first week of August 2021.
Copied
Expected results
Your results
More Tiktok questions
ID | Title | Level | FTPR |
---|---|---|---|
168 | Average number of streams in the US tiktok | medium |
|
169 | Same day streams tiktok | easy |
|
170 | Top 3 countries by average watch time tiktok | easy |
|
171 | Binge watches tiktok | easy |
|