如何循环字段并计算
我有一个表,有以下字段
name100,name105...name300,value100,value105...value300,unit,carton
需要计算name100/value100,name105/value105.....name300/value300,如果每个都能整除,则将unit更新为1,carton等于各个结果之和;否则unit为0,carton为0
以上,如果在存储过程中实现
谢谢
------解决方案----------------------try
update tbName set
unit=case when name100%value100=0 and name105%value105=0 then 1 else 0 end,
carton=case when name100%value100=0 and name105%value105=0 then name100/value100+name105/value105 else 0 end