update patient
set patient.f_54=(casewhenpatient.f_32 like'死亡'
then a.z-1
when patient.f_32 is null
then a.z
else patient.f_54 end )
from (select 住院号,count(*) zfrom dbo.t1 group by 住院号) a , patient
WHERE
right(a.住院号,10)=patient.f_2 and
left(CONVERT(CHAR(100), patient.f_23,23),7)='2012-01'
或者 多个字段名更新:
update tbo_invoice_extractor
set pga_status = (case pga_status
when 1 then 0
when 3 then 0
else pga_status
end),
rd_status = (case rd_status
when 1 then 0
when 3 then 0
else rd_status
end)
where ……