Use a CTE in a query
You can use a common table expression (CTE) to simplify creating a view or table, selecting data, or inserting data.
You can use a common table expression (CTE) to simplify creating a view or table, selecting data, or inserting data.
CREATE TABLE s2 AS WITH q1 AS (SELECT key FROM src WHERE key = '4') SELECT * FROM q1;
CREATE VIEW v1 AS WITH q1 AS (SELECT key FROM src WHERE key='5') SELECT * from q1;
WITH q1 AS (SELECT key from src where key = '5') SELECT * from q1;
CREATE TABLE s1 LIKE src; WITH q1 AS (SELECT key, value FROM src WHERE key = '5') FROM q1 INSERT OVERWRITE TABLE s1 SELECT *;