题解 | 统计加班员工占比



with temp as (
    select      
        department,
        count(a.staff_id) as cnt,
        count(if((unix_timestamp(last_clockin)-unix_timestamp(first_clockin))/3600>9.5,1,null)) as ban_cnt
        from staff_tb a join attendent_tb b
        on a.staff_id=b.staff_id group by  department)

select 
    department,
    concat(round((ban_cnt/cnt)*100,1),'%') as ratio
    from temp order  by ratio desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务