Common Table Expressions

suggest change

Syntax

SELECT …

)

SELECT … FROM QueryName …;

SELECT …

UNION [ALL]

SELECT … FROM QueryName …

)

SELECT … FROM QueryName …;

Remarks

SQLite documents the WITH clause here. The RECURSIVE keyword is required by some dialects, such as PostgreSQL, and is not used by SQL Server.

A common table expression is a temporary result set, and it can be the result of a complex subquery. It is defined with a WITH clause. A CTE improves readability. It lasts only for the statement that defines it. In SQL Server it is not stored in tempdb the way a temporary table or table variable is.

Key concepts of Common Table Expressions:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents