Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
inbs
Aged Yak Warrior
860 Posts |
Posted - 2012-10-22 : 11:43:08
|
[code]Qunt Date Classify Cumulative RowNo 50 17.06 S 50 1100 22.06 R 50 220 24.06 S 70 3[/code]i have cumulative table, but i have some logic buisness here,1.how can cumulative just rows ,that cumulative of row 1 (50) is lower than Qnt of row 2, so i put the last qnt in cumulative in row 22.in row 3 the qnt 20 is lower than 50 so i added 50+20.any helpthanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-22 : 12:11:26
|
do you mean this?UPDATE tSET t.Cumulative= CASE WHEN t.Qunt > t1.Cumulative THEN t1.Qunt ELSE t1.Cumulative + t.Qunt ENDFROM table tINNER JOIN table t1On t1.RowNo = t.RowNo-1 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
inbs
Aged Yak Warrior
860 Posts |
Posted - 2012-10-22 : 14:16:11
|
but i do not have RowNo column,this was for the example |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-22 : 14:39:37
|
then what determines your sequence? is there a datetime column? otherwise you cant guarantee order of rerieval------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|