题解 | 统计各岗位员工平均工作时长

统计各岗位员工平均工作时长

https://www.nowcoder.com/practice/b7220791a95a4cd092801069aefa1cae

select  a.post,round(avg((UNIX_TIMESTAMP(last_clockin) - UNIX_TIMESTAMP(first_clockin)) / 3600),3)
work_hours from staff_tb a 
join attendent_tb b using(staff_id)
where b.first_clockin is not null and b.last_clockin is not null
group by a.post order by  work_hours desc

UNIX_TIMESTAMP(last_clockin) - UNIX_TIMESTAMP(first_clockin)) / 3600 计算精确到秒的日期差,/3600为小时差 /60 为分钟差

全部评论

相关推荐

2025-12-13 14:51
已编辑
井冈山大学 算法工程师
龙虾x:算法比你强的没有你美,比你美的…..算了已经没有比你美的了
工作两年想退休了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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