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

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

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

with a as (select x.course_id,course_name,in_datetime as dt,1 as nb from attend_tb x join course_tb y using(course_id) union all select x.course_id,course_name,out_datetime as dt,-1 as nb from attend_tb x join course_tb y using(course_id) order by 3,4), b as (select a.course_id,a.course_name,sum(a.nb) over (partition by a.course_id order by a.dt) as at_time from a) select b.course_id,b.course_name,max(b.at_time) from b group by 1,2 order by 1

全部评论

相关推荐

jack_miller:我给我们导员说我不在这里转正,可能没三方签了。导员说没事学校催的时候帮我想办法应付一下
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务