Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A        B     C           D            E
ItemID  weight Service     Eventdate   weightgain or lost(Col B)
16568906    24  Programme   05/10/2015  
16568906    24  Trainer     05/10/2015      0
16568906    29  Programme   28/01/2016      5
16568906    29  Trainer     28/01/2016      0
168906      23  Trainer     29/01/2016  
168906      20  Trainer     30/01/2016     -3
1656890610  28  Programme   05/10/2015  
1656890610  35  Programme   06/10/2015      7
1656890610  30  Programme   07/10/2015     -5



=IF(A1=A2,B2-B1) give result in col E

What I have tried:

I'm trying to replicate an excel formulae in Sql and I have try to use cumulative value but never work
Posted
Updated 22-Feb-16 6:57am
v2

1 solution

All what you're looking for is called cumulative sum or running totals or running sum.

Start here: Calculating simple running totals in SQL Server[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900