我試圖在BigQuery中運行一個查詢,它有兩個子選擇和一個連接,但我無法讓它工作。我正在做的一個解決方法是自行運行子查詢,然後將它們保存爲表,然後使用連接執行另一個查詢,但我認爲我應該可以使用一個查詢來完成此操作。谷歌BigQuery要求加入每個,但我已經在使用它
,我發現了錯誤:
Table too large for JOIN. Consider using JOIN EACH. For more details, please see https://developers.google.com/bigquery/docs/query-reference#joins
,但我已經在使用一個連接各。我嘗試過使用交叉連接和每個組使用組,但這些給我不同的錯誤。關於這個主題的堆棧溢出的其他問題沒有幫助,一個說這是一個在BigQuery中的錯誤,另一個是有人使用'交叉連接每個'...
以下是我的SQL,原諒我,如果它已滿錯誤的,但我認爲它應該工作:
select
t1.device_uuid,
t1.session_uuid,
t1.nth,
t1.Diamonds_Launch,
t2.Diamonds_Close
from (
select
device_uuid,
session_uuid,
nth,
sum(cast([project_id].[table_id].attributes.Value as integer)) as Diamonds_Launch
from [project_id].[table_id]
where name = 'App Launch'
and attributes.Name = 'Inventory - Diamonds'
group by device_uuid, session_uuid, nth
) as t1
join each (
select
device_uuid,
session_uuid,
nth,
sum(cast([project_id].[table_id].attributes.Value as integer)) as Diamonds_Close
from [project_id].[table_id]
where name = 'App Close'
and attributes.Name = 'Inventory - Diamonds'
group by device_uuid, session_uuid, nth
) as t2
on t1.device_uuid = t2.device_uuid
and t1.session_uuid = t2.session_uuid
謝謝Pentium10,我想應該有辦法用一條SELECT語句做這件事,但我無法弄清楚。 – Davidjb 2015-02-24 22:22:56