题解 | #牛客直播各科目同时在线人数#

牛客直播各科目同时在线人数

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

select course_id, course_name, max(so) as max_num
from (
    select course_id,sum(uv) over(partition by course_id order by dt) as so
    from (
        select course_id, user_id, in_datetime as dt, 1 as uv
        from attend_tb
        union 
        select course_id, user_id, out_datetime as dt, -1 as uv
        from attend_tb
    ) a
) b join course_tb using(course_id)
group by course_id, course_name
order by course_id

全部评论

相关推荐

10-04 17:25
门头沟学院 Java
snqing:Java已经饱和了,根本不缺人。随便一个2000工资的都200人起投递
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务