数据库中 有 A B C D E字段 。
a =b + c + d
a b c d e
10 2 2 6
11 7 2 2
15 2 10 3
现在想求出来b c d 中最大的结果值写到E 中 ,可以实现吗?
------解决方案--------------------
create table test (a int,b int ,c int,d int,e int)
insert into test values(10,2,2,6,null)
insert into test values(11,7,2,2,null)
insert into test values(15,2,10,3,null)
update test set e=case when b>=c and b>=d then b
when c>=b and c>=d then c
when d>=b and d>=c then d
end
select * from test
/*
10 2 2 6 6
11 7 2 2 7
15 2 10 3 10
*/