select c.user_id as user_id,c.room_id as room_id,room_type, datediff(checkout_time,checkin_time) as days from guestroom_tb g right join checkin_tb c on g.room_id=c.room_id and checkin_time like '2022-06-12%' where datediff(checkout_time,checkin_time)>1 order by days,room_id,user_id desc