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

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

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大厂面试题题解~

全部评论

相关推荐

notbeentak...:孩子,说实话,选择很重要,可能你换一个方向会好很多,但是现在时间不太够了,除非准备春招
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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