SQL Reference Guide > SQL Reference Guide > SQL Statements > WITH (common_table_expression)
Was this helpful?
WITH (common_table_expression)
Valid in: SQL, ESQL, DBProc, OpenAPI, ODBC, JDBC, .NET
A Common Table Expression (CTE) is a temporary named result set, derived from a simple query and defined within the execution scope of a SELECT or INSERT statement. It is like a derived table or inline view.
CTEs can appear in the following contexts:
SELECT
CREATE TABLE…AS SELECT
DECLARE GLOBAL TEMPORARY TABLE…AS SELECT
INSERT INTO…SELECT
CREATE VIEW
For more information and examples, see Common Table Expressions (CTEs).
Last modified date: 11/09/2022