最近我开始从事 BigQuery 工作,但有些事情仍然让我感到困惑。 Big Query 上的此查询的替代方案是什么?
select a.abc, c.xyz
from table1 as a
left join table2 as c
on a.abc = c.abc
and c.date = (select t.date from table3 t)
问题是 Big Query 不支持连接中的子查询。我尝试了很多替代方案,但结果彼此不匹配。
最佳答案
假设 table3.date
是唯一的,请尝试编写如下查询:
select a.abc, c.xyz
from table1 a left join
(table2 c join
table3 t
on c.date = t.date
)
on a.abc = c.abc;
如果table3
中有重复项,您可以将其表述为:
select a.abc, c.xyz
from table1 a left join
(table2 c join
(select distinct date
from table3 t
) t
on c.date = t.date
)
on a.abc = c.abc;
关于sql - BigQuery - 连接谓词中不支持带表的子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69293947/