Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

Union of multiple CTE'S

$
0
0

Hello,

I have a piece of code which goes like this ---

A]

with cte1 AS (

), cte2 as (

),

select a,b,c

B]

with cte3 AS (

), cte4 as (

),

select x,y,z.

I need a way to union these 2 result sets. I can't write all 4 concurrently and then select as I would need to uniquely identify elements in each SET A and SET B. One approach i see is to put result set of each in a temp table and then finally do union all with temp tables. Would like suggestions or any other better way. As i have aboout 8 of such similar individual sets.

Thanks


Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>