How can I have multiple common table expressions in a single SELECT statement?

前端 未结 2 1355
[愿得一人]
[愿得一人] 2021-01-30 00:18

I am in the process of simplifying a complicated select statement, so thought I would use common table expressions.

Declaring a single cte works fine.

WI         


        
2条回答
  •  情话喂你
    2021-01-30 00:27

    I think it should be something like:

    WITH 
        cte1 as (SELECT * from cdr.Location),
        cte2 as (SELECT * from cdr.Location)
    select * from cte1 union select * from cte2
    

    Basically, WITH is just a clause here, and like the other clauses that take lists, "," is the appropriate delimiter.

提交回复
热议问题