数据库中,表一sum得出一个值,赋给表二的某个字段,为null

尝试使用了isnull(arg1,arg2)函数表示无效

最后运用了COALESCE(arg1,arg2,arg3,...)

该函数标识返回参数中第一个不为null的值.

update  a

set

a.overplus=a.howMany -

(

select COALESCE(sum(b.USENUMBER),0)  

from b

where b.belongAFId = a.id

)

原文地址:https://www.cnblogs.com/vmax-tam/p/5336130.html