300 ms Runtime Solution in PostgreSQL
\n\n# Code\n\n-- Write your PostgreSQL query statement below\nSELECT machine_id, ROUND(CAST(AVG(duration) as numeric), 3) as processing_time \nFROM (\nSELECT a.
\n\n# Code\n```\n-- Write your PostgreSQL query statement below\nSELECT machine_id, ROUND(CAST(AVG(duration) as numeric), 3) as processing_time \nFROM (\nSELECT a.machine_id, \n    (select b.timestamp from activity b where b.activity_type = \'end\' and a.machine_id = b.machine_id and a.process_id = b.process_id) - (select c.timestamp from activity c where c.activity_type = \'start\' and a.machine_id = c.machine_id and c.process_id = a.process_id) duration\nFROM Activity a) q\nGROUP BY q.machine_id\nORDER BY machine_id\n```
[]