Advanced SQL
Chapter 23 - Common Table Expressions
- Use a Common Table Expression (CTE) to simplify a query
- CTEs act like virtual tables with rows and columns
- They are defined while a statement is executed
- The statement uses their results
- Their scope ends when the statement finishes
- A CTE often provides an intermediate transformation of source-table data for the main query
- A CTE is a named result set, defined using a SELECT statement, that can be referenced by the statement that follows it.