我想在BigQuery中连接三个表;表1具有一个事件的记录(即,每行是一条记录),表2具有第二事件的记录,并且表3具有类别名称。三个表的BigQuery连接
我要产生具有按类别和设备平台的表1和表2计数决赛桌。但是,每次运行时,我都会收到一个错误消息,说明joined.t3.category不是加入中任一表的字段。
这里是我当前的代码:
Select count(distinct joined.t1.Id) as t1_events, count(distinct t2.Id) as t2_events, joined.t1.Origin as platform, joined.t3.category as category
from
(
SELECT
Id,
Origin,
CatId
FROM [testing.table_1] as t1
JOIN (SELECT category,
CategoryID
FROM [testing.table_3]) as t3
on t1.CatId = t3.CategoryID
) AS joined
JOIN (SELECT Id,
CategoryId
FROM [testing.table_2]) as t2
ON (joined.t1.CatId = t2.CategoryId)
Group by platform,category;
仅供参考,这里的表1和表2完美的作品之间的简单连接:
Select count(distinct t1.Id) as t1_event, count(distinct t2.Id) as t2_events, t1.Origin as platform
from testing.table_1 as t1
JOIN testing.table_2 as t2
on t1.CatId = t2.CategoryId
Group by platform;
您是真正的MVP--这项工作非常完美。 –