Monday, June 13, 2011

Cumulative Sum in SQL Server

http://stackoverflow.com/questions/2120544/how-to-get-cumulative-sum


declare  @t table (
    id int
,
    SomeNumt int 
)



 
insert into @select 1,10 union select 2,12 union select 3,3 union select 4,15 union select 5,23

 
select * from @




select t1.id, t1.SomeNumt, SUM(t2.SomeNumt) as sum from @t t1 inner join @t t2 on t1.id >= t2.id group by t1.id, t1.SomeNumt order by t1.id 

No comments:

Post a Comment

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...