题解 | #牛客直播各科目出勤率#

牛客直播各科目出勤率

https://www.nowcoder.com/practice/0cab547df4f0430b93042128f445d899

select 
    t2.course_id,
    t2.course_name,
    round(100*cnt/total,2)
from(
select 
    course_id,
    course_name,
    count(distinct if(tm>=10,user_id,null)) as cnt
from(
        select
            user_id,
            course_id,
            course_name,
            sum(timestampdiff(minute,if(course_datetime > in_datetime,course_datetime,in_datetime),out_datetime)) as tm
        from 
            attend_tb as a
    left join course_tb as b
    using(course_id)
    where 
        user_id in (
            select 
                user_id
            from 
                behavior_tb
            where 
                if_sign = 1
        )
    group by 1,2,3) as t
group by 1,2) as t1
right join(
select 
    course_id,
    course_name,
    sum(if_sign) as total
from 
    behavior_tb
left join course_tb 
using(course_id)
group by 1,2) as t2
on t1.course_id = t2.course_id
order by course_id asc

全部评论

相关推荐

06-15 18:44
黄淮学院 Java
Lynn012:如果是居民楼还是算了吧,看着有点野呢
点赞 评论 收藏
分享
风中翠竹:真的真的真的没有kpi。。。面试官是没有任何kpi的,捞是真的想试试看这个行不行,碰碰运气,或者是面试官比较闲现在,没事捞个人看看。kpi算HR那边,但是只有你入职了,kpi才作数,面试是没有的。
双非有机会进大厂吗
点赞 评论 收藏
分享
身边有人上海、深圳 6、7k 都去了,真就带薪上班了。
程序员小白条:木的办法, 以后越来越差,还是家附近宅着吧,毕业的人越来越多,岗位都提供不出来,经济又过了人口红利期
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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