Compounded SUM in SQL Server -
this question has answer here:
is possible compounded sum in sql server? e.g.
month salary total
jan 1000 1000
feb 1200 2200
mar 1000 3200
. . .
. . .
please help.
declare @t table( months varchar(10), salary int) insert @t select 'jan', 1000 union select 'feb', 1200 union select 'mar', 1000 ;with cte ( select *,row_number()over(order (select null))rn @t ) ,cte1 ( select a.*,salary [total] cte rn=1 union select a.*,a.salary+total cte inner join cte1 b on a.rn-b.rn=1 ) select * cte1
Comments
Post a Comment