34,591
社区成员
发帖
与我相关
我的任务
分享
with a(f1,f2,f3,f4) as(
select 0,1,2,3 union all
select 1,2,3,5 union all
select 0,5,5,5)
select f1,f2,f3,case when f1=0 then f2+f3 else f2-f3 end as 结果 from a
/*
f1 f2 f3 结果
0 1 2 3
1 2 3 -1
0 5 5 10
*/
update T
set F4=case when F1=0 then F2+F3
else F2-F3 end