September 17, 2010 at 2:25 am
Dear Experts,
I have an interesting problem here.
I have a two values on a row. Say value A = 5000 and Value B = 20000. Value A changes from row to row but Value B is constant. I would like to deduct Value A from B such that Value B keeps decreasing cummulatively with each row. Such as on Row 1 the Variance would be 15,000 from 20000-5000
On Row 2 where Value A is 3000, I would like to have 15000 - 3000 = 12000 and so on. How can I achieve this programmatically ?
September 17, 2010 at 2:57 am
Did you have a look at Jeffs great article : "Solving the "Running Total" & "Ordinal Rank" Problems (Rewritten)" http://www.sqlservercentral.com/articles/T-SQL/68467/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 17, 2010 at 11:47 am
The pseudo cursor method would surely work..
you could also try looping over the table based on the row_number() function and store the previous derived value in a temp variable A.
You can use the value of A in the next row value..
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply