clear markdown help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1579822 fiddles created (21367 in the last week).

CREATE TABLE IF NOT EXISTS RECORDS ( ID INT, T TIME ); INSERT INTO RECORDS VALUES (1,'12:10:00'), (1,'12:10:05'), (1,'12:11:00'), (1,'13:04:03'), (2,'14:18:05'), (2,'15:00:09'), (3,'17:33:50'), (1,'20:03:14'), (1,'20:03:55'), (1,'20:10:23');
10 rows affected
10 rows affected
 hidden batch(es)


SELECT DISTINCT tt.ID, FIRST_VALUE(t) OVER W AS start FROM (SELECT t.*, ROW_NUMBER() OVER(ORDER BY t) - ROW_NUMBER() OVER(PARTITION BY ID ORDER BY t) AS rn FROM (SELECT ID, t FROM records) t) tt WINDOW W AS (PARTITION BY rn ORDER BY t ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) ORDER BY start
id start
1 12:10:00
2 14:18:05
3 17:33:50
1 20:03:14
id start
1 12:10:00
2 14:18:05
3 17:33:50
1 20:03:14
 hidden batch(es)