A BEGINNER'S GUIDE TO GET TO THE SOLUTION 
IntuitionTry to read the solution along side the table and trust me you will get this.My first intuition was to get a table with columns : -

Machine_id and pro
# Intuition
Try to read the solution along side the table and trust me you will get this. 

My first intuition was to get a table with columns : -
 1. Machine_id and processing_time (processing_time column should have the difference of timestamp from same process_id and machine_id, as we don't want to get difference of timestamp having same process_id but different machine_id)

2. The difference of timestamp should be positive. (To ensure that we get "end-start" and not "start-end" )

3. Once you manage to get these two columns using join, then you just have to use round, avg and group by functions to get the final result.

# Approach
- Select the columns. Get the average of processing_time and Round it off.
- Use join.
- Put the conditions.(mentioned in point 1 and 2 of intuition)
- Use group by machine_id.



# Code
```mysql []
SELECT a1.machine_id, round(avg(a1.timestamp - a2.timestamp),3) as processing_time
from activity as a1
join 
activity as a2
on a1.machine_id=a2.machine_id and a1.process_id=a2.process_id and
a1.timestamp - a2.timestamp > 0 
group by a1.machine_id

```


There can be other optimised solutions as well but I find this approach easy for a beginner. 
['MySQL']