SELECT r.room_id, r.room_name, COUNT(DISTINCT u.user_id) AS online_users FROM user_view_tb u LEFT JOIN room_info_tb r ON u.room_id = r.room_id WHERE u.in_time <= '24:00:00' AND u.out_time >= '23:00:00' GROUP BY r.room_id,r.room_name ORDER BY online_users DESC;