clear markdown compare 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. 1044250 fiddles created (9457 in the last week).

CREATE TABLE tickets (id int, timestamp timestamp, ticket_id int) ;
 hidden batch(es)


INSERT INTO tickets (id, timestamp, ticket_id) VALUES ( 2, '2016-06-16 09:14:00', 1466089815), (10, '2016-06-27 08:15:00', 1466089815), ( 3, '2016-06-16 09:14:00', 1466089816), (11, '2016-06-27 08:15:00', 1466089816), (13, '2016-06-27 08:50:00', 1466089816) ;
 hidden batch(es)


select ticket_id, timediff(max(timestamp), min(timestamp)) as diff, timestampdiff(hour, min(timestamp), max(timestamp)) as diff_in_hours, timestampdiff(minute, min(timestamp), max(timestamp)) as diff_in_minutes, timestampdiff(second, min(timestamp), max(timestamp)) as diff_in_seconds from tickets group by ticket_id ;
ticket_id diff diff_in_hours diff_in_minutes diff_in_seconds
1466089815 263:01:00 263 15781 946860
1466089816 263:36:00 263 15816 948960
 hidden batch(es)