sqlgoogle-bigquerycommon-table-expression

WITH in BigQuery


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

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;

Solution

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

    See also how to Enabling Standard SQL