题解 | #牛客直播开始时各直播间在线人数#

牛客直播开始时各直播间在线人数

http://www.nowcoder.com/practice/bdd30e83d47043c99def6d9671bb6dbf

一开始做麻烦了,按照之间求瞬时最大uv的方法来做,结果发现完全没必要

  1. 先找到 19:00 上课情况,就是 in-time 以及out-time覆盖 19:00这个时间点的
select *
    from attend_tb
    inner join course_tb
    using(course_id)
    where '19:00:00' between time(in_datetime)  and time(out_datetime)
  1. 然后按照course_id, course_name分组统计uv就好,在按照course_id升序排列
select
    course_id,
    course_name,
    count(distinct user_id) as online_num
    from attend_tb
    inner join course_tb
    using(course_id)
    where '19:00:00' between time(in_datetime)  and time(out_datetime)
    GROUP BY course_id, course_name
    order by course_id
全部评论

相关推荐

北斗导航Compass低仿版:没必要写这么多东西,还是尽量浓缩成一页,自我评价,git和cursor Trae这些都可以去掉。实习经历的描述最好根据star法则改一下,别这么直白
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务