Hello all I have the following CTE...what I'm trying to do is have an Id and then a concatenated list of Status
so for example...if I have
1, 1234, Hot
2, 1234, Cold
3, 1234, Warm
I want to end up with
1234,'Hot,Cold,Warm'
My CTE
with recursive temp_table(RowNumber, Id, Status) as (
select
row_number() over (order by OBJECT_STATUS ) as RowNumber
,OBJECT_ID
,cast(OBJECT_STATUS as varchar(100)) as Status
from
CORE_ORDER_STATUS
where
OBJECT_ID = 'OR000008387722'
union all
select
a.RowNumber + 1 as NextOne
,b.OBJECT_ID
,a.Status || ',' || cast(b.OBJECT_STATUS as varchar(5)) as Status
from
CORE_ORDER_STATUS b
inner join
temp_table a
on
a.Id = b.OBJECT_ID
where
a.RowNumber = b.NextOne
)
select * from temp_table;