题解 | 统计加班员工占比
统计加班员工占比
https://www.nowcoder.com/practice/6c0a521c36e14c7599eaef858f6f8233
SELECT department, CONCAT(ROUND( 100 * SUM(TIMESTAMPDIFF(SECOND, first_clockin, last_clockin)/3600 > 9.5) / COUNT(DISTINCT s.staff_id), 1 ), '%') AS ratio FROM staff_tb s LEFT JOIN attendent_tb a USING(staff_id) GROUP BY department ORDER BY ratio DESC