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

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

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

with a as(select user_id, course_id, in_datetime as time, 1 as uv
from attend_tb
union all
select user_id, course_id, out_datetime as time, -1 as uv
from attend_tb),
b as(select *, sum(uv)over(partition by course_id order by time) as zaixian
from a
order by course_id, time)
select b.course_id, c.course_name, max(b.zaixian) max_num
from b left join course_tb c on b.course_id=c.course_id
group by 1,2

全部评论

相关推荐

12-03 03:32
安徽大学 Java
点赞 评论 收藏
分享
影04714:把图书管理系统那个项目经验内容适当的减少掉,然后改成据为己有不要说团队项目,因为图书管理系统这类常见的谁来了都能独立写出来,提问能圆过来即可
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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