What is a CTE?medium
Answer
A common table expression is a named temporary result inside a query.
Explanation
CTEs make complex SQL easier to read by breaking logic into named steps. Some databases may materialize them, while others optimize them inline.
Follow-upWhen would you prefer a CTE over a subquery?