很高兴认识你,亲爱的社区!我想从几个表中选择自注册日起不迟于 7 天执行最后一次活动的用户,并按他们的开始版本对他们进行分组。
但是,选择的用户数量很少,您能告诉我我哪里出错了吗?
FROM (SELECT user_id, country, user_creation_time, event_type, event_time, start_version
FROM PUBLIC.export_07_2020
UNION
SELECT user_id, country, user_creation_time, event_type, event_time, start_version
FROM PUBLIC.export_08_2020
UNION
SELECT user_id, country, user_creation_time, event_type, event_time, start_version
FROM PUBLIC.export_09_2020) dat
WHERE dat.country = 'United States'
AND dat.user_creation_time BETWEEN
'2020-07-01 00:00:00' AND '2020-09-23 23:59:59'
AND NOT EXISTS (SELECT dit.user_id
FROM (SELECT user_id,
country,
user_creation_time,
event_type,
event_time
FROM PUBLIC.export_07_2020
UNION
SELECT user_id,
country,
user_creation_time,
event_type,
event_time
FROM PUBLIC.export_08_2020
UNION
SELECT user_id,
country,
user_creation_time,
event_type,
event_time
FROM PUBLIC.export_09_2020) dit
WHERE dat.user_id = dit.user_id
AND Greatest(dit.event_time) >
Dateadd(day, 7, dit.user_creation_time))
GROUP BY dat.start_version```