En måde er at give et unikt indeks for hver kørsel/serie og derefter bruge GROUP BY til at få start- og sluttidsstempler.
Her går du:
SELECT COUNT(*), MIN(time_stamp) AS starttime, MAX(time_stamp) AS endtime
FROM (
SELECT IF(@prev <> marker, @s:[email protected]+1, @s:[email protected]) AS `index`,
time_stamp, @prev:=marker marker
FROM
tbl, (SELECT @s:= 0, @prev:= -1) s
) tmp
WHERE marker = 1
GROUP BY `index`
Working fiddle:http://sqlfiddle.com/#!2/f5f19c/3