我陷入了SQL查询中,请问您能帮我吗?也许我不明白这个问题的意思:
Bigquery SQL for sliding window aggregate
我想获取登录用户的数量(每天-DAU),并紧跟属于“重度用户”细分并且过去30天一直在该细分中的用户数量。
>我已经到了:
SELECT
event_date,
count(distinct(a.user_pseudo_id)) as dau,
(SELECT count(distinct(user_pseudo_id))
FROM `api-project-XXXXX.XXXXX.framework_mobile_analytics` b
WHERE DATE(TIMESTAMP(b.event_date)) BETWEEN
DATE_ADD(DATE(TIMESTAMP(a.event_date)) , INTERVAL -30 DAY) AND
DATE_ADD(DATE(TIMESTAMP(a.event_date)), INTERVAL -1 DAY)
AND key like "Heavy users%") as heavy_users
FROM
`api-project-XXXXX.XXXXX.events_2019*` a
WHERE
a.event_name = "login"
group by 1
order by 1
但是它给了我这个错误:
LEFT OUTER JOIN cannot be used without a condition that is an equality of fields from both sides of the join.
我不太了解,您能帮助您理解查询还是建议我另一种获取理想表的方法?
所以我理想的输出表如下:
event_date dau heavy_users
20190931 124000 75000 (count of heavy users between 20190901 - 20190930)
20191001 111000 95000 (count of heavy users between 20190902 - 20190931)
20191002 122000 85000 (count of heavy users between 20190903 - 20191001)
20191003 154000 84000 (count of heavy users between 20190904 - 20191002)
谢谢!