Simple MySQL solution (CTE, GROUP BY, SUM, CASE WHEN)
\n# Write your MySQL query statement below\nWITH t AS (\n    SELECT\n        machine_id,\n        process_id,\n        SUM(CASE WHEN activity_type=\'start\' THE
```\n# Write your MySQL query statement below\nWITH t AS (\n    SELECT\n        machine_id,\n        process_id,\n        SUM(CASE WHEN activity_type=\'start\' THEN timestamp ELSE 0 END) AS start_time,\n        SUM(CASE WHEN activity_type=\'end\' THEN timestamp ELSE 0 END) AS end_time\n    FROM Activity\n    GROUP BY machine_id, process_id\n    ORDER BY machine_id, process_id\n)\nSELECT\n    machine_id,\n    ROUND(AVG(end_time-start_time), 3) AS processing_time\nFROM t\nGROUP BY machine_id\nORDER BY machine_id;\n```
['MySQL']