Activity
table and alias it as a
for 'start' timestamps and b
for 'end' timestamps.a
and b
on machine_id
and process_id
where a.activity_type
is 'start' and b.activity_type
is 'end'.a.timestamp
from b.timestamp
.machine_id
.machine_id
and the calculated average processing time as processing_time
.erDiagram Activity { int machine_id int process_id enum activity_type float timestamp }