sql 1661

sql 1661

image-20241115152750451

保留小数:ROUND(x,y)求参数x的四舍五入的值,保留y位小数

思路:分两表分别查线程对应的start和end然后相减

# Write your MySQL query statement below
select a1.machine_id,ROUND(2*sum(a1.timestamp-a2.timestamp)/count(*),3) processing_time
    from Activity a1 left join Activity a2
    on a1.machine_id=a2.machine_id 
    && a1.process_id=a2.process_id
    && a1.activity_type='end'
    && a2.activity_type='start'
    group by a1.machine_id;
posted @ 2024-11-15 15:31  vast_joy  阅读(17)  评论(0)    收藏  举报