Last active
May 31, 2022 00:55
-
-
Save cqusyc/6b8bcad29fc239dcad2fa2bfc7eadc05 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 /* 归并购买相同的菜品等级,按用户计数 */ | |
user_pseudo_id, | |
COUNT(user_pseudo_id) as user_count | |
FROM ( | |
SELECT /* 查询最高菜品等级 */ | |
user_pseudo_id, event_timestamp | |
FROM | |
`analytics_195246954.events_*` AS T, | |
T.event_params | |
WHERE | |
event_name = 'af_shop_buy_food' | |
AND event_params.key = 'af_food_id' | |
AND event_params.value.int_value = 2 | |
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 '20181209' AND '20181209' /* 修改为激活日期范围 */ | |
) | |
AND _TABLE_SUFFIX BETWEEN '20181219' AND '20181220' /* 修改为从激活到要查询的留存日期范围 */ | |
) | |
GROUP BY user_pseudo_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment