Common Table Expressions (CTE)

A CTE is a temporary result set defined within the execution scope of a single query. It improves readability and supports recursion.

Syntax

WITH CTEName AS (
    SELECT ...
)
SELECT * FROM CTEName;