CTE

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”

Happy Coding Everyday~ 快乐编码,享受生活~
原文地址:https://www.cnblogs.com/tedzhang/p/3556351.html