题解 | 统计加班员工占比

select
    department,
    concat (round(sum(判断) / count(*) * 100, 1), '%') ratio
from
    (
        select
            department,
            timestampdiff (minute, first_clockin, last_clockin) 分钟数,
            if (
                timestampdiff (minute, first_clockin, last_clockin) > 570,
                1,
                0
            ) 判断
        from
            test.staff_tb st
            join test.attendent_tb att on st.staff_id = att.staff_id
    ) a
group by
    department
order by
    ratio desc

全部评论

相关推荐

06-12 16:00
天津大学 Java
牛客30236098...:腾讯坏事做尽,终面挂是最破防的 上次被挂了后我连简历都不刷了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务