I have a CTE like this:
WITH source1 as (
SELECT blah FROM blah
), source2 as (
SELECT moreblah FROM source1)
SELECT * FROM source2;
I want to insert the results of this query into a table, but when I write this:
WITH source1 as (
SELECT blah FROM blah
), source2 as (
SELECT moreblah FROM source1)
INSERT INTO newtable SELECT * FROM source2;
It says I have a syntax error Expected "(" or "," or keyword SELECT but got keyword INSERT. I'm wondering if this is a Bigquery issue b/c I've looked at other places like this which say my INSERT INTO should work. Any help would be appreciated!
In BigQuery, the WITH goes with the SELECT:
INSERT INTO newtable
WITH source1 as (
SELECT blah FROM blah
),
source2 as (
SELECT moreblah FROM source1
)
SELECT *
FROM source2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With