1661. 每台机器的进程平均运行时间 - 力扣(LeetCode)
知识点 :
- 自查询
- 动脑子分析 + 会一步步调试
- 聚合函数
- 数值函数round
select
a.machine_id,
round((sum(b.timestamp - a.timestamp) / count(a.process_id)), 3) as processing_time
from
Activity as a,
Activity as b
where
a.activity_type = 'start' and b.activity_type = 'end'
and
a.machine_id = b.machine_id and a.process_id = b.process_id
group by a.machine_id;