2
我有一個場景,在這裏我運行2個單獨的更新查詢。 如何通過使用案例將這些組合成單個查詢?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'