BigQuery 是否允许使用 SQL `with` 子句进行多表连接?

问题描述 投票:0回答:0

BigQuery 是否允许使用 SQL

with
子句进行多表连接?

例子:

WITH t1 as (select tab1, tab2 from t1 group by 1,2), 
t2 as ( select tab1, tab2, tab3, from t2 group by 1,2,3)
t3 as ( select tab1, tab2, from t3 group by 1,2,3)

我可以通过多次重复相同的查询来使下面的查询工作,但不想,并且想利用它

with as

SELECT a.tab1, a.tab2, b.tab1, b. tab3, c.tab1, c.tab2
FROM  t1 a
LEFT JOIN t2 b
ON a.tabl = b.tab1 and a.tab2 = b.tab3
LEFT JOIN t3 c
ON a.tab1 = c.tab1

SELECT a.tab1, a.tab2, b.tab1, b. tab3, c.tab1, c.tab2
FROM  t1 a
LEFT JOIN t2 b
ON a.tabl = b.tab1 and a.tab2 = b.tab3
LEFT JOIN t3 c
ON a.tab1 = c.tab1
sql join google-bigquery left-join with-clause
© www.soinside.com 2019 - 2024. All rights reserved.