Can I make two update statment on one cte without doing two Cte?

when I try to make two update statment on same cte it not accept so How to do two update statment on same cte

or any other way can help me to do only two update on one processes

with ctegetMINvalue as
(
select PART_ID,DKFeatureName,Value,ValueUnit,row_number() over (partition by PART_ID order by ValueUnit asc) as RowNumber from #FinalTable
WHERE splitflag=1 and statusid=3
)
update f set f.Value=ct.ValueUnit  from #SplitNumberAndUnits f inner join ctegetMINvalue ct on f.PART_ID=ct.PART_ID and f.DKFeatureName=ct.DKFeatureName where RowNumber=1


;with ctegetMAXvalue as
(
select PART_ID,DKFeatureName,Value,ValueUnit,row_number() over (partition by PART_ID order by ValueUnit asc) as RowNumber from #FinalTable
WHERE splitflag=1 and statusid=3
)
update f set f.MaxValue=ct.ValueUnit  from #SplitNumberAndUnits f inner join ctegetMAXvalue ct on f.PART_ID=ct.PART_ID and f.DKFeatureName=ct.DKFeatureName where RowNumber=2

I need to make two update statement above on same cte but not accept so what I do ?

are there are any way can help me to do two update as one proceses

Please first respond to answers that other have worked hard to answer for your questions

1 Like