✅MySQL | clear and simple approach  ✨
Query\n\n# Write your MySQL query statement below\nWITH start AS (\n    SELECT machine_id, process_id, activity_type, timestamp FROM Activity\n    WHERE activit
# Query\n```\n# Write your MySQL query statement below\nWITH start AS (\n    SELECT machine_id, process_id, activity_type, timestamp FROM Activity\n    WHERE activity_type=\'start\'\n),\nends AS (\n    SELECT machine_id, process_id, activity_type, timestamp FROM Activity\n    WHERE activity_type=\'end\'\n)\n\nSELECT s.machine_id, \n       ROUND((SUM(e.timestamp) - SUM(s.timestamp))/COUNT(e.machine_id), 3) AS processing_time\nFROM start s\nJOIN ends e\nON e.machine_id = s.machine_id AND e.process_id = s.process_id\nGROUP BY e.machine_id\n\n```\n\n\nThe above query might seem long and there are other approaches to obtain the solution(using JOINS). I just want to implement distinct queries in each problem.\n\n*if you find its helpful* **please upvote**
['MySQL']