Posted by Neha, Jan. 19, 2022, 12:48 a.m.
Q.181 discussion
Q. 181
Users who watched less than one hour of Netflix
Write a query to find all users who have watched less than 1 hour of content within one week of signing up.
Table 1: netflix_account
col_name | col_type
-------------+---------------------
account_id | bigint
country | character varying(2)
created_dt | date
Table 2: netflix_daily_streaming
Daily aggregated watch time by account by content.
col_name | col_type
--------------+---------------------
date | date
account_id | bigint
content_id | bigint
duration | int -- in seconds
-------------------------------------------------------------------------------------------
SELECT DISTINCT account_id FROM
netflix_account AS a
INNER JOIN netflix_daily_streaming AS s
ON a.account_id = s.account_id
WHERE created_dt - date = 7 AND duration < 3600
Users who watched less than one hour of Netflix
Write a query to find all users who have watched less than 1 hour of content within one week of signing up.
Table 1: netflix_account
col_name | col_type
-------------+---------------------
account_id | bigint
country | character varying(2)
created_dt | date
Table 2: netflix_daily_streaming
Daily aggregated watch time by account by content.
col_name | col_type
--------------+---------------------
date | date
account_id | bigint
content_id | bigint
duration | int -- in seconds
-------------------------------------------------------------------------------------------
SELECT DISTINCT account_id FROM
netflix_account AS a
INNER JOIN netflix_daily_streaming AS s
ON a.account_id = s.account_id
WHERE created_dt - date = 7 AND duration < 3600