Created
March 29, 2019 06:35
-
-
Save cqusyc/4594d5aacd3aac7185f89ff40a988c74 to your computer and use it in GitHub Desktop.
[查询流失用户某等级的点击水壶分布] #BigQuery #MergeGarden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
A.user_pseudo_id, | |
sum(A.tap_count) as tap_count | |
FROM | |
( | |
SELECT user_pseudo_id, event_params.value.int_value AS tap_count, event_timestamp | |
FROM | |
`analytics_195246954.events_*` AS T, | |
T.event_params | |
WHERE | |
event_name = 'af_click_tap_button' | |
AND event_params.key = 'af_count' | |
AND _TABLE_SUFFIX BETWEEN '20181209' AND '20181210' /* 修改为从注册到要查询的留存日期范围 */ | |
AND user_pseudo_id IN ( | |
SELECT | |
DISTINCT user_pseudo_id | |
FROM | |
`analytics_195246954.events_*` AS T, | |
T.event_params | |
WHERE | |
event_name = 'first_open' | |
AND geo.country = 'United States' /* 修改为指定国家 */ | |
AND platform = 'ANDROID' | |
AND _TABLE_SUFFIX BETWEEN '20181219' AND '20181219' /* 修改为注册日期范围 */ | |
EXCEPT DISTINCT /* 排除留存用户 */ | |
SELECT | |
DISTINCT user_pseudo_id | |
FROM | |
`analytics_195246954.events_*` AS T, | |
T.event_params | |
WHERE | |
event_name = 'user_engagement' | |
AND geo.country = 'United States' /* 修改为指定国家 */ | |
AND platform = 'ANDROID' | |
AND _TABLE_SUFFIX BETWEEN '20181220' AND '20181220' /* 修改为留存日期范围 */ | |
) | |
) AS A, | |
( | |
SELECT /* 查询最高菜品等级 */ | |
user_pseudo_id, event_timestamp | |
FROM | |
`analytics_195246954.events_*` AS T, | |
T.event_params | |
WHERE | |
event_name = 'af_click_tap_button' | |
AND event_params.key = 'level' | |
AND event_params.value.int_value = 2 | |
AND _TABLE_SUFFIX BETWEEN '20181219' AND '20181220' /* 修改为从激活到要查询的留存日期范围 */ | |
) AS B | |
WHERE A.user_pseudo_id = B.user_pseudo_id AND A.event_timestamp = B.event_timestamp | |
GROUP BY user_pseudo_id /* 按伪用户id去重 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment