我的BigQuery中有两个日期参数,一个是第一次打开的日期(First_open),另一个是取值的日期( date )。我需要找到在特定日期打开的用户集(Id),以及他们在接下来的7天内的值,而不是更多。
例如:
1 6月20日(First_open)用户应仅在6月7日之前(日期)
6月20日(First_open)用户应仅保留到6月8日(日期)
6月20日(First_open)用户应仅保留到6月13日(日期)
SELECT
event_name,
COUNT(DISTINCT id) uniques,
COUNT(id) as total
FROM
`x-12.analytics_7.xyz`
WHERE
(first_open between "2020-06-01" and "2020-06-07")
AND (date BETWEEN "20200601" AND "20200613")
AND event_names in ("app_open","first_open")
AND platform = "ANDROID"
GROUP BY
event_names正如您从我使用的查询中看到的,我将用户限制为7天开放,但我不能将他们的值限制为仅7天。
发布于 2020-06-24 18:55:16
根据您的描述,您可以使用COUNTIF()
SELECT event_name, COUNT(DISTINCT id) uniques, COUNT(id) as total,
COUNTIF(date <= DATE_ADD(first_open, interval 7 day))
FROM `x-12.analytics_7.xyz`
WHERE first_open between '2020-06-01' and '2020-06-07' and
date BETWEEN '2020-06-01' AND '2020-06-13- and
event_names in ('app_open', 'first_open') and
platform = 'ANDROID'
GROUP BY event_names;或者,您可以将逻辑放在WHERE子句中:
WHERE first_open between '2020-06-01' and '2020-06-07' and
date >= first_open and
date < date_add(first_open, interval 7 day) and
event_names in ('app_open', 'first_open') and
platform = 'ANDROID' https://stackoverflow.com/questions/62553376
复制相似问题