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

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

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

select t6.course_id,t6.course_name,max(sum_diff) from (
select t4.course_id,t5.course_name 
,sum(diff) over(partition by t4.course_id order by t4.dt asc,t4.diff desc) as sum_diff 
from (
select * from (
select t1.user_id,t1.course_id,t1.in_datetime as dt,1  as diff 
from attend_tb as t1 
union all 
select t2.user_id,t2.course_id,t2.out_datetime as dt ,-1 as diff 
from attend_tb as t2 ) t3 ) t4 
left join course_tb as t5 on t4.course_id = t5.course_id) t6 
group by t6.course_id,t6.course_name 
order by t6.course_id

全部评论

相关推荐

06-12 16:00
天津大学 Java
牛客30236098...:腾讯坏事做尽,终面挂是最破防的 上次被挂了后我连简历都不刷了
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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