'How do you save a join as a Snowflake table?

I understand how a Join is made in Snowflake but I need to temporarily save it as a table, how can it be possible make it using consola?

(For this project I can't do it with any connectors)



Solution 1:[1]

You are looking for the CREATE TABLE AS SELECT or CTAS pattern:

CREATE TABLE tmp_table AS 
SELECT a.*, b.* 
FROM (SELECT * FROM VALUES ('a'),('b')) a(string)
CROSS JOIN (SELECT * FROM VALUES (1),(2)) b(vals); 

SELECT * FROM tmp_table;

gives:

STRING VALS
a 1
a 2
b 1
b 2

and if you want it to be temporary for the session you might want to add TEMP

CREATE TEMP TABLE tmp_table AS 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simeon Pilgrim