我有三个具有相同列数和结构的查询,Google BigQuery是否支持联合所有?我知道它支持union,但我需要它将查询结果合并到一个结果中。
我试过了:
SELECT *
FROM
(SELECT a.a AS a, a.b AS b, d.c AS c FROM table_a a JOIN table_d d on d.a = a.a),
(SELECT c.a AS a, c.b AS b, d.c AS c FROM table_c c JOIN table_d d on d.a = ca.a),
(SELECT b.a AS a, b.b AS b, d.c AS c FROM table_b b JOIN table_d d on d.a = b.a)
我收到以下错误:
Union results in ambiguous schema [d.c] is ambiguous and is aliasing multiple fields
谢谢你的帮助。
答案 0 :(得分:1)
您是否知道数据是来自表a,b还是c?如果您不需要知道,可以尝试以下查询:
select *
from
(select a, b
from table_a, table_b, table_c) as a
join
(select a, c
from table_d) as d
on a.a = d.a