题解 | 统计加班员工占比

统计加班员工占比

https://www.nowcoder.com/practice/6c0a521c36e14c7599eaef858f6f8233

select *
from(select t1.department ,
case  when overtime/totalnumber is null then concat(round(0*100.0,1),'%')
else  concat(round(overtime/totalnumber*100,1),'%')
end  ratio
from
(select department ,count(department) totalnumber
from  staff_tb
group by department
)t1  left join 
(select department,count(workhour) overtime
from  staff_tb  join
(
select staff_id, round(timestampdiff(second,first_clockin,last_clockin)/3600,1) workhour
from attendent_tb
)t
on  staff_tb.staff_id= t.staff_id
where workhour>9.5 
group by department )t2
on t1.department=t2.department
)t3
order by ratio desc 

全部评论

相关推荐

02-26 09:15
已编辑
蚌埠学院 golang
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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