题解 | 统计加班员工占比

WITH t1 AS(
    SELECT 
    staff_id,
    IF(timestampdiff(MINUTE,first_clockin,last_clockin)/60>9.5,'overtime','usual') as status
    FROM attendent_tb
)
SELECT 
department,
concat(round(COUNT(CASE WHEN status = 'overtime' THEN 1 END)/COUNT(status)*100,1),'%') as ratio
FROM staff_tb JOIN t1 USING(staff_id)
GROUP BY department
ORDER BY ratio DESC

全部评论

相关推荐

11-27 16:41
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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