多个WITH语句和CREATE TABLE,这是创建表的正确方法



我面临的一个挑战是如何创建一个表,但从以前操作其他表的操作来看,但我似乎无法在最后一步创建表。例如,我的查询如下:

WITH recs as (
SELECT product_id
FROM `table1`,
),
filtered as (
select * from recs where product_id is not null
),

CREATE OR REPLACE TABLE `newtable` AS
(
select * from recs where product_id is not null
)

我得到错误:

Syntax error: Expected "(" or "," or keyword SELECT but got keyword CREATE at [21:5]

使用下面的

CREATE OR REPLACE TABLE `newtable` AS (
WITH recs as (
SELECT product_id
FROM `table1`
), filtered as (
select * from recs where product_id is not null
)
select * from recs where product_id is not null
)

最新更新