if else within CTE ?
Posted
by stackoverflowuser
on Stack Overflow
See other posts from Stack Overflow
or by stackoverflowuser
Published on 2010-05-25T18:22:32Z
Indexed on
2010/05/25
18:31 UTC
Read the original article
Hit count: 239
I want to execute select statement within CTE based on a codition. something like below
;with CTE_AorB
(
if(condition)
select * from table_A
else
select * from table_B
),
CTE_C as
(
select * from CTE_AorB // processing is removed
)
But i get error on this. Is it possible to have if else within CTEs? If not is there a work around Or a better approach.
Thanks.
© Stack Overflow or respective owner