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

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

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

select t.course_id, course_name, max(num) as max_num
from(
select a1.course_id, count(distinct a2.user_id) as num
from attend_tb a1 join attend_tb a2 
on a1.course_id = a2.course_id and a1.out_datetime > a2.in_datetime and a1.out_datetime <= a2.out_datetime
group by 1, a1.user_id)t join course_tb c on t.course_id = c.course_id
group by 1,2
order by 1

找有时间交叉的就行了 然后计数

全部评论

相关推荐

08-05 18:14
门头沟学院 Java
小花的沉默:是学历厂没错啊,学历太高了不要
投递小鹏汽车等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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