При самостоятельном присоединении:
select c1.employee_id,
c1.created_at `start`, min(c2.created_at) `end`,
time_format(timediff(
min(c2.created_at),
c1.created_at
), "%H:%i") total
from clock_activities c1 inner join clock_activities c2
on c1.employee_id = c2.employee_id
and c1.activity = 'start_break' and c2.activity = 'end_break'
and c1.created_at < c2.created_at
group by c1.employee_id, c1.created_at
См. Демоверсию . Результаты:
| employee_id | start | end | total |
| ----------- | ----- | ---- | ----- |
| 1 | 1:00 | 1:10 | 00:10 |
| 1 | 2:00 | 2:10 | 00:10 |
| 1 | 2:30 | 2:45 | 00:15 |
| 1 | 3:10 | 3:20 | 00:10 |