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

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

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

相关推荐

秋招不是要开始了吗,我都打算润了,看大家还在找不敢润了
一条从:因为不是人人都像佬一样有实习像我们这种二本仔秋招没有实习也是白忙活
点赞 评论 收藏
分享
重生我想学测开:嵌入式的问题,我准备入行京东外卖了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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