I am having trouble with something I want to get from a database table.
The table looks like this
startTime endTime type
1:00 1:02 A
1:20 1:30 A
3:45 3:50 A
1:30 1:40 B
2:30 2:31 A
3:00 3:01 A
...
I want to get the average time gap (starttime of next A action minus starttime of this) on each type of action.
How am I suppose to do it?
Edit:
There is a rule. If the interval is bigger than 1 hour than it does not count towards the average. Therefor it is not equal to the whole time interval divided by the number of intervals. So it becomes, (just for A)
startTime endTime type
1:00 1:02 A
1:20 1:30 A
2:30 2:31 A
3:00 3:01 A
3:45 3:50 A
The calculation should be 1:20 - 1:00 = 20 min (take this record) 2:30 - 1:20 = 70 min (discard this record ) 3:00 - 2:30 = 30 min (take this) 3:45 - 3:00 = 45 min (take this)
The final result should be (20+30+45) / 3