SQL ✅ |  Subquery ✅✅| Easy to understand
ApproachThe solution is achieved through subqueries (This solution is also understandable and wonderful)Code
 # Approach
# The solution is achieved through subqueries (This solution is also understandable and wonderful)

![image.png](https://assets.leetcode.com/users/images/d67077d9-6579-44bb-99dd-2128950dc5d4_1736919294.8959167.png)



# Code
```mysql []
# Write your MySQL query statement below
select 
a.machine_id,
round(
      (select avg(a1.timestamp) from Activity a1 where a1.activity_type = 'end' and a1.machine_id = a.machine_id) - 
      (select avg(a1.timestamp) from Activity a1 where a1.activity_type = 'start' and a1.machine_id = a.machine_id)
,3) as processing_time
from Activity a
group by a.machine_id
```
['MySQL']