Cumulative sum based on criteria

  • Hey all,

    I am trying to go through this table (see attached), and then for every change in LOC_Zone, record the average amount of time that a certain loczone takes up. For example, for the UTILGLAVA loc_zone I would need to sum the amount of time that has passed until the next loc zone appears (in this case 29102). I would then sum the amount of time spent in 29102 until the next loc zone (integeosc). The process would repeat with the average time spent in each loc_zone being my final desired result.

    Is this possible to do in sql alone, or do I need to use some other scripting language?

    Thanks for your help guys!

    -Andrew

  • You should know that those who want to help you are more than likely to be at their work place ... working .... could you supply the table definition, a small amount of data ... in an easily useable format. To do that click on the first link in my signature block and the article that will display has sample T-SQL code that will let you do that quickly and easily.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I'm sorry. Thanks alot for letting me know. Tomorrow when I am back at work I will correctly post the data. I appreciate your help.

    -Andrew

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply