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

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

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

with st as
(
    select course_id,in_datetime
    from attend_tb at
    group by course_id,in_datetime
)
select a.course_id,course_name,max(cnt) max_num from
(select *,(select sum(case when
st.in_datetime >=at.in_datetime and st.in_datetime<=at.out_datetime then 1
else 0 end)
from attend_tb at where at.course_id=st.course_id
) as cnt from st)a,course_tb ct
where a.course_id=ct.course_id
group by a.course_id,course_name
order by a.course_id
全部评论
最关键的是求cnt部分:(select sum(case when st.in_datetime >=at.in_datetime and st.in_datetime<=at.out_datetime then 1 else 0 end) from attend_tb at where at.course_id=st.course_id) as cnt
点赞 回复 分享
发布于 2022-01-19 21:26

相关推荐

06-18 15:03
门头沟学院 Java
至少实习看起来比去年好?问了下群里的同学和身边的同学,人均有offer。有的还有好几个大厂offer
菜鸟1973:上一年暑期也是人均大厂实习offer,结果秋招跟不招人一样,大部分都转正了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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