Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Cumulative sum based on criteria Expand / Collapse
Author
Message
Posted Monday, February 04, 2013 3:07 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 05, 2013 11:20 AM
Points: 2, Visits: 1
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


  Post Attachments 
table.JPG (7 views, 609.96 KB)
Post #1415509
Posted Monday, February 04, 2013 3:32 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:02 PM
Points: 5,100, Visits: 20,195
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

Before posting a performance problem please read
Post #1415513
Posted Tuesday, February 05, 2013 11:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 05, 2013 11:20 AM
Points: 2, Visits: 1
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
Post #1416011
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse