SQL BigQuery 中的 WITH

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37423022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:37:08  来源:igfitidea点击:

WITH in BigQuery

sqlgoogle-bigquerycommon-table-expression

提问by cshin9

Does BigQuery support the WITHclause? I don't like formatting too many subqueries.

BigQuery 是否支持该WITH子句?我不喜欢格式化太多子查询。

For example:

例如:

WITH alias_1 AS (SELECT foo1 c FROM bar)
, alias_2 AS (SELECT foo2 c FROM bar a, alias_1 b WHERE b.c = a.c)
SELECT * FROM alias_2 a;

采纳答案by Mikhail Berlyant

Recently introduced BigQuery Standard SQL does support WITH clause
See more about WITH clause

最近推出的 BigQuery Standard SQL 确实支持 WITH 子句
查看更多关于WITH 子句

See also how to Enabling Standard SQL

另请参阅如何启用标准 SQL

回答by Harish

Bigqery Standard SQl is supporting WITH clause. Syntax is as shown below

Bigqery 标准 SQL 支持 WITH 子句。语法如下图

with table2 as (Select column1,column2 from table1)
    select column1 from table2