Why use CTE:
- Improve code readability
- Breaking up complex queries into smaller blocks
Execution Scope:
Don’t use “Go” keyword between CTE and the reference query, only the query that following CTE could use it.
For multiple query definitions in CTW, use UNION ALL, UNION, INTERSECT, EXCEPT
You can create multiple CTEs, separate them with ‘,’instead of “WITH”