题解 | 牛客直播开始时各直播间在线人数

牛客直播开始时各直播间在线人数

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

select t1.course_id, course_name,
count(distinct 
case 
when t1.course_id=1 and '2021-12-1 19:00' between in_datetime and out_datetime then user_id
when t1.course_id=2 and '2021-12-2 19:00' between in_datetime and out_datetime then user_id
when t1.course_id=3 and '2021-12-3 19:00' between in_datetime and out_datetime then user_id
end) as online_num
from course_tb t1 inner join attend_tb t2 
on t1.course_id = t2.course_id
group by t1.course_id, course_name  
order by t1.course_id

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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