create table #test(year int,mon int,value int)
insert into #test(year,mon,value) values(2021,1,100)
insert into #test(year,mon,value) values(2021,2,200)
insert into #test(year,mon,value) values(2021,3,340)
insert into #test(year,mon,value) values(2021,4,550)
insert into #test(year,mon,value) values(2021,5,760)
insert into #test(year,mon,value) values(2021,6,890)
select a.*,case when a.mon>1 then a.value-b.value else a.value end as value1 from #test a,#test b where a.year=b.year and a.mon-1=b.mon
value1就是每月的