【发布时间】:2016-11-09 07:26:22
【问题描述】:
我有一张这样的桌子
header: source, user, metric1, metric2,...
data:
source1, user1, metrics..
source1, user2, metrics..
source2, user1, metrics..
source3, user1, metrics...
source3, user3, metrics...
...
我想为每个来源都找不到的用户汇总一些指标。 在上面的示例中,我想为 source2 提取:users2 和 user3 并获取 avg 或它们的指标。
调查类似:
select avg(metric1) from tbl as tbl1
where user is not in
(select user from tbl as tbl2 where tbl1.source=tbl2.source)
group by source
根据文档页面,上述查询不适用于旧版 SQL:
(https://cloud.google.com/bigquery/docs/reference/legacy-sql)
但在 ANSI 中有,但我得到了Resources exceeded
【问题讨论】:
-
如果您发布工作 ID,Google 人员可以为您深入挖掘
-
即使您为 source2 提供了预期的“逻辑”,我仍然看到很多方法来解释这一点!您也可以提供对 source1 和 source3 的期望吗?它可能会消除不确定性!
-
@MikhailBerlyant - 不知道你的意思。我正在尝试在一个名为 source 的字段上单独加入该表。 IE。我需要找到所有用户(user 字段的唯一值),而不是找到每个刚刚找到的用户的所有行,并在 metric1 字段上获取所有这些行的平均值>
-
但您还提到了“......对于每个来源都没有找到的用户......”这让它有点模糊。所以这就是为什么我要求你为 source1 和 source3 提供预期的输出 - 这可以澄清你到底需要什么
标签: google-bigquery