select post, -- 计算总分钟数,然后除以 60 得到小时数 round(avg(TIMESTAMPDIFF(MINUTE, first_clockin, last_clockin) / 60),3) AS work_hours from staff_tb a join attendent_tb b on a.staff_id = b.staff_id where first_clockin is not null and last_clockin is not null group by post order by work_hours desc
- 简单场景、旧数据库、大数据量:选该方法,性能优、兼容性好;

京公网安备 11010502036488号