select user_id,c.room_id,room_type,datediff(checkout_time,checkin_time) as days from checkin_tb as c left join guestroom_tb as g # on c.room_id=g.room_id using(room_id) where date(checkin_time)>='2022-06-12' and datediff(checkout_time,checkin_time)>=2 order by days asc,room_id asc,user_id desc...