Can you create nested WITH clauses for Common Table Expressions?

后端 未结 7 1178
花落未央
花落未央 2020-12-12 10:42
WITH y AS (
    WITH x AS (
        SELECT * FROM MyTable
    )
    SELECT * FROM x
)
SELECT * FROM y

Does something like this work? I tried it ear

7条回答
  •  遥遥无期
    2020-12-12 11:07

    we can create nested cte.please see the below cte in example

    ;with cte_data as 
    (
    Select * from [HumanResources].[Department]
    ),cte_data1 as
    (
    Select * from [HumanResources].[Department]
    )
    
    select * from cte_data,cte_data1
    

提交回复
热议问题