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

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

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

# 时间:4/16 11:00 ~ 

# 明确问题:统计的是19:00 时刻的在线人数!
# 方法:maybe sum()over()进行累计统计  (no) 只需要筛选保留符合条件时间段的数据
# 字段:course_id、course_name、online_num


# tb1:筛选时间段包含了19:00的数据\
with tb1 as(
    select distinct user_id , course_id ,course_name,course_datetime
    from attend_tb left join course_tb using(course_id)
    # where in_datetime =< course_datetime and out_datetime >= course_datetime
    where course_datetime between in_datetime and out_datetime
)

# tb2:聚合输出结果
select course_id,course_name,count(user_id) as online_num
from tb1
group by course_id,course_name

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-15 17:46
暑期就挂了,秋招还有机会吗
大聪明777:研发提前批,14号刚开的,官网上面的配图上有写。提前批没过的话,秋招还可以投,不过前面的笔试/面试记录会被保留,供秋招参考
26届校招投递进展
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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