8. SQL Statements : WITH (common_table_expression)
 
Share this page                  
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 similar to 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) (see page Common Table Expressions (CTEs)).