题解 | #牛客直播开始时各直播间在线人数#
牛客直播开始时各直播间在线人数
https://www.nowcoder.com/practice/bdd30e83d47043c99def6d9671bb6dbf
select
a.course_id,c.course_name,count(user_id) as online_num
from attend_tb a left join course_tb c
on a.course_id = c.course_id
-- 方式一:使用right函数截取
where right(in_datetime, 8) <= '19:00:00' and right(out_datetime, 8) >= '19:00:00'
-- 方式二:使用date_format格式化取对应时间
# where date_format(in_datetime, '%H:%i') <='19:00' and date_format(out_datetime,'%H:%i') >= '19:00'
group by a.course_id,c.course_name
order by a.course_id
SQL大厂面试题 文章被收录于专栏
牛客网sql大厂面试题题解~

