1
SQL
Условие
Таблица reports_stg.watch_content (просмотры видео):
user_id video_id date
=================================
1 1 2021-01-01
1 2 2021-01-01
1 3 2021-02-15
2 1 2019-12-31
2 2 2020-07-01
3 4 2022-12-10
4 1 2022-12-11
5 1 2021-01-01
5 3 2021-02-15Поля:
user_id— идентификатор пользователяvideo_id— идентификатор просмотренного видеоdate— дата просмотра видео
1. Задача: Вывести список пользователей, смотревших видео 1 и 3, но не смотревших видео 2
with cte as (
select distinct user_id
from reports_stg.watch_content
where video_id = 1
)
select distinct user_id
from reports_stg.watch_content
where user_id in (select user_id from cte) and video_id = 3
except
select…