SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


elapsed for overlap time


elapsed for overlap time

Author
Message
CS-1058423
CS-1058423
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 111
Hi guys,
i need help to fine a good approach to generate an algorithm that measures time range only in overlapping time range.
The scenario:
I have a typical trouble ticket, this can be in different status (open, in progress, paused...).
It can be assigned for different working teams (business, tech...)
Every trouble ticket can have sub-ticket end every sub-ticket can have the same scenario like the main's one.
What i need is to count the seconds in overlapping time range where the trouble ticket has been in specific woprking status and specific working group.
Scenario:
<---open---><--in progress-----><---pause-------><--in progress--><closed>TT STATUS
<--Group1------><----Group2--------------><-------------Group1---------->TT GROUP
..........<-open-><--in progress---><pause----><-in progress------><--closed>SUBTT STATUS
..........<--Group1------><----Group2--------------><-----Group1----------->SUBTT GROUP


So the time range i need to measure is only the overlap time when the ticket (and if one exists, its sub ticket) is in:
status: in progress, open
group : group 1

Every help is appreciated.
Cris
Luis Cazares
Luis Cazares
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17246 Visits: 19122
I'm not sure what you need. I couldn't understand. It would help a lot if you posted table definitions (DDL statements), sample data (Insert statements) and expected output based on that sample data.
Read the article on my signature for guidance on how to do it.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
dwain.c
dwain.c
SSCertifiable
SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)

Group: General Forum Members
Points: 7639 Visits: 6431
As Luis has said, any direct help from this forum is going to need you to provide us DDL, sample data and expected results.

But at a guess, I'd say there might be something in Itzik Ben-Gan's Packing Intervals article that will work for your case.


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
CS-1058423
CS-1058423
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 111
Thanks for your suggest guys,
i'm reading the document about time packing intervals. When done and if needed i'll post some DDL to replicate the scenario.

Ciao.
C
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search