I have a SQL table that looks kind of like the following
entry_ID type_of_entry time_of_entry
1 0 12:00
2 0 12:05
3 1 12:15
4 0 15:14
5 1 15:30
What I'm hoping to do is extract the times taken between the first 0 in the type of entry chain, and the 1 to end the chain. The number of 0 type_of_entry rows between the 1s will vary.
So for this table I would want:
TIMEDIFF(12:15 , 12:00) = 15 mins
TIMEDIFF(15:30 , 15:14) = 16 mins
How can I get the groupings I want, ideally without looping through the table with a FOR EACH?