Guidelines for Using CTEs
A CTE is introduced into a query using the WITH clause preceding the outermost SELECT keyword. It can be used in combination with query statements or with INSERT, CREATE TABLE, DEFINE GLOBAL TEMPORARY TABLE, and CREATE VIEW.
The CTE can be a list of named subquery expressions separated by commas, each being able to reference ordinary tables and views but also able to refer to WITH elements in the same query that precede its definition. A CTE cannot refer to another in the same query that is defined later in the query.
The ability for a CTE to reference itself as in a recursive manner is not supported.
CTE definitions do not have an INTO clause or ORDER BY but can otherwise contain general subquery syntax including UNION and DISTINCT.
Last modified date: 08/14/2024