WITH (CTE)
Common Table Expressions give a name to a subquery that can be referenced multiple times in the main query. CTE using SELECT:Multiple CTEs
Define multiple CTEs in a singleWITH block. Later CTEs may reference earlier ones:
Scalar Subquery in WHERE
A subquery that returns a single value can be used in a comparison:Correlated Subquery in WHERE
The subquery references a column from the outer query:Subquery in FROM (Derived Table)
Not Supported
WITH RECURSIVE(recursive CTEs)- Scalar subquery in the
SELECTlist (e.g.,SELECT (SELECT MAX(x) FROM t), id FROM ...) - Subquery in
HAVINGorORDER BY