I would like to calculate the downtime for some processes.
My data could look like this:
Proces ID StartTime EndTime
A 1 24-07-2018 00:00:00 24-07-2018 00:02:54
A 2 24-07-2018 00:00:16 24-07-2018 00:02:55
A 3 24-07-2018 11:12:42 24-07-2018 11:15:10
A 4 24-07-2018 00:00:16 24-07-2018 00:02:55
In this example, ID 1, 2 and 4 are overlapping, but the downtime should only be from 00.00.00 to 00.02.55 plus the downtime for ID 3.
I am not sure how to compare all the times and only getting it to use the overlapping time once.
If it is unclear, then ask!
I hope someone can help me.
i think is better that handle this business Out of TSQL , For example in your Application you can get each day and use a bitarray for each minute and calculate minimum and maximum Time in each overlapping range . this is very complex in tsql and i thinks every solution has Performance ISSUE.