im looking to save data from a select query into a new table using snowflake. Usually i use the
create or replace table as select...
but this time i cannot get this to work because i am referencing many temp tables, and the queries within these temp tables eg transactions and sales is very complex, so i do not want to write one large query. Eg the layout of my code is something like this :
set start_date = '2021-06-01';
with transactions as ( select * from .....),
with sales as (select * from ....),
with customers as (select * from .....),
with results as (select * from ....),
create or replace table newresults as select * from results
please can anyone help me safe the results into a new table newresults? thanks
CodePudding user response:
You have to change your structure slightly.
CREATE OR REPLACE TABLE NEWRESULTS AS
WITH transactions as (SELECT * FROM ...),
sales AS (SELECT * FROM ...),
customers AS (SELECT * FROM ...),
results AS (SELECT * FROM ...)
SELECT * FROM results;