1
SQL задачи
Практика1. Задача: Вывести список пользователей, смотревших video_id 1 и 3 (посмотрел и видео 1, и видео 3), но не смотревших 2
select
user_id
from
(
select
user_id,
max(case when video_id = 1 then 1 else 0 end) as has_1_video,
max(case when video_id = 2 then 1 else 0 end) as has_2_video,
max(case when video_id = 3 then 1 else 0 end) as has_3_video
from reports_stg.watch_content
group by user_id
) t
where has_1_video = 1
and has_3_video = 1
and has_2_video = 02. Задача: Для каждого пользователя вывести наименование и цену самого дорогого товара в его первой транзакции
with first_user_order as
(
select
user_id,
item_id,
min(transaction_datetime) as…