你没有为 @day 做初始,所以没有结果:declare @day int ,@acurd numeric(10,3),@avga numeric(10,3)set @day=0 --如果不用这个,@day=@day+1 的值始终为null,因为null+任何值都是nullupdate workers set @day=@day+1, @acurd=case when @day=60 then (select avg(isnull(b.sailer,0)) from (select top 60 sailer from workers where num='20000001' order by updtime asc) as b) when @day>60 then (isnull(sailer,0)-isnull(@acurd,0))*0.15+isnull(@acurd,0) else 0 end ,SAI=@acurd where num='20000001'
@acurd=case
when @day=60 then (select avg(isnull(b.sailer,0)) from (select top 60 sailer from workers where num='20000001' order by updtime asc) as b)
when @day>60 then (isnull(sailer,0)-isnull(@acurd,0))*0.15+isnull(@acurd,0)
else 0 end ,SAI=@acurd
where num='20000001'