Detailed explanation of JOIN, ROUND, AVG, GROUP BY.
Approach\nTo solve this problem, 1st we need to join the same table, so we will have starting time and ending time in the same line:\n\n\nselect a1.machine_id, 
# Approach\nTo solve this problem, 1st we need to join the same table, so we will have starting time and ending time in the same line:\n\n```\nselect a1.machine_id, a1.timestamp, a2.timestamp\nfrom Activity a1\njoin Activity a2\non a1.process_id=a2.process_id\nand a1.machine_id=a2.machine_id\nand a1.timestamp<a2.timestamp;\n\n| machine_id | timestamp | timestamp |\n| ---------- | --------- | --------- |\n| 0          | 0.712     | 1.52      |\n| 0          | 3.14      | 4.12      |\n| 1          | 0.55      | 1.55      |\n| 1          | 0.43      | 1.42      |\n| 2          | 4.1       | 4.512     |\n| 2          | 2.5       | 5         |\n```\n\nnow we can calculate the difference between timestamps, group the values by machine_id and round average value of differences\n\n```\nselect a1.machine_id\n, ROUND(AVG(a2.timestamp - a1.timestamp),3) as processing_time\nfrom Activity a1\njoin Activity a2\non a1.process_id=a2.process_id\nand a1.machine_id=a2.machine_id\nand a1.timestamp<a2.timestamp\ngroup by a1.machine_id;\n\n| machine_id | processing_time |\n| ---------- | --------------- |\n| 0          | 0.894           |\n| 1          | 0.995           |\n| 2          | 1.456           |\n```\n\nPlease upvote if you like my explanation. Good luck!\n\n
['MySQL', 'Oracle', 'MS SQL Server']