我想在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--這項工作非常完美。 –