I have a scenario here where i am running 2 separate update queries.
How can I combine those into a single query by use of case?
UPDATE TABLE1 SET ACTV_IND = 0
WHERE NAME IN (
select NAME
from TABLE1
where SID = 'child'
group by NAME
having MAX(CAST(ACTV_IND AS INT)) =0
)
AND SID = 'parent'
UPDATE TABLE1 SET ACTV_IND = 1
WHERE NAME IN (
select NAME
from TABLE1
where SID = 'child'
group by NAME
having MAX(CAST(ACTV_IND AS INT)) =1
)
AND SID = 'parent'
Q1: I think this might be the solution
Q2: It is possible to use join for update
I would try something this like this, assuming that MAX(CAST(ACTV_IND AS INT)) will return 0 or 1