locked
Running Total Query/Cursor RRS feed

  • Question

  • Hi All,

    I need help in deriving an running total by means of a query or sp or cursor

    (The values given as CSV)

    ID,Time,Time(hour),Time(Min),Time(sec),Cond1,Cond2,Cond3,
    305,400,17,32,59,25,23.5,150,
    306,403,17,32,59,25,23.5,150,
    307,405,17,33,0,25,23.5,150,
    308,406,17,33,2,25,23.5,150,
    309,408,17,33,4,25,23.5,150,

    409,598,17,43,54,25,23.5,150,
    410,599,17,43,54,25,23.5,150,
    411,600,17,43,55,25,23.5,150,
    412,601,17,43,55,25,23.5,150,
    413,603,17,43,56,25,23.5,150,
    414,605,17,43,56,25,23.5,150,

    The second column Time & the next three column (Time (Hours), TIme(Min), Time(Sec) are for whihc I require the running total. so that my final result would be as

    ID,Time,Time(hour),Time(Min),Time(sec),Cond1,Cond2,Cond3,RunningTotalTime,RunningTotal
    305,400,17,32,59,25,23.5,150,0,0
    306,403,17,32,59,25,23.5,150,3(400-403),0
    307,405,17,33,0,25,23.5,150,5(400-405),1
    308,406,17,33,2,25,23.5,150,6,3
    309,408,17,33,4,25,23.5,150,8,5

    409,598,17,43,54,25,23.5,150,0,0
    410,599,17,43,54,25,23.5,150,1,0
    411,600,17,43,55,25,23.5,150,2,1
    412,601,17,43,55,25,23.5,150,3,1
    413,603,17,43,56,25,23.5,150,5,2
    414,605,17,43,56,25,23.5,150,7,2

    here the RunningTotalTIme ans RunningTotalTimesec gives the running total.

    I need a query to get the achieve it ...

    Thanks

    • Changed type Naomi N Thursday, November 22, 2012 3:55 PM Question rather than discussion
    Thursday, November 22, 2012 5:51 AM

Answers

All replies