无法弄清楚如何使用多个CTE
这失败了
; with [cteOne] as (
select 1 as col
),
[cteTwo] as (
select 2 as col
)
select 'yesA' where exists (select * from [cteOne])
select 'yexB' where exists (select * from [cteTwo])
Run Code Online (Sandbox Code Playgroud)
这有效 - 但这不是我需要的
; with [cteOne] as (
select 1 as col
),
[cteTwo] as (
select 2 as col
)
select * from [cteOne]
union
select * from [cteTwo]
Run Code Online (Sandbox Code Playgroud)
真正的语法是row_number()分区的连接
我刚刚使用派生表