提前 set @kk=0 设值,会无效 select @kk=sum(字段名) from 表名 需加判断 if @kk is null set @kk=0 ,才能保证值为0,否则所有的与@KK相连,都会为NULL.