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



简单偷个懒