This is an SQL problem I can't wrap my head around in a simple query Is it possible?
The data set is (letters added for ease of understanding):
Start End
10:01 10:12 (A)
10:03 10:06 (B)
10:05 10:25 (C)
10:14 10:42 (D)
10:32 10:36 (E)
The desired output is:
PeriodStart New ActiveAtEnd MinActive MaxActive
09:50 0 0 0 0
10:00 3 (ABC) 2 (AC) 0 3 (ABC)
10:10 1 (D) 2 (CD) 1 (C) 2 (AC or CD)
10:20 0 1 (D) 1 (C) 2 (CD)
10:30 1 (E) 1 (D) 1 (D) 2 (DE)
10:40 0 0 0 1 (D)
10:50 0 0 0 0
So, the query needed is a summary of the first table, calculating the minimum overlapping time periods (Start-End) and the maximum overlapping time periods (Start-End) from the first table within a 10 minute period.
'New' is the number of rows with a Start in the summary period. 'ActiveAtEnd' is the number of rows active at the end of the summary period.
I'm using Oracle, but I'm sure a solution can be adjusted. Stored procedures not allowed - just plain SELECT/INSERT (views are allowed). Its also OK to run one SQL command per 10 minute output (as once populated, that will be how it keeps up to date.
Thanks for any ideas, including 'not possible' ;-)