【大厂真题】SQL29题解 | 短视频直播间晚上11-12点之间各直播间的在线人数
# 开始和结束时间都有可能存在延期 # SELECT a.room_id, b.room_name,count(DISTINCT a.user_id) as user_count from user_view_tb a left join room_info_tb b on a.room_id=b.room_id where (in_time>='23:00:00' and in_time<='23:59:59') OR (out_time>='23:00:00' and out_time<='23:59:59') group by a.room_id, b.room_name order by user_count desc
#where in_time <= '23:59:59'
#and out_time >= '23:00:00'