select
c.user_id as user_id,
c.room_id as room_id,
g.room_type as room_type,
day(c.checkout_time) - day(c.checkin_time) as days
from
guestroom_tb g,
checkin_tb c
where
g.room_id = c.room_id
and day(c.checkout_time) - day(c.checkin_time) > 1
order by days asc ,c.room_id asc ,c.user_id desc

京公网安备 11010502036488号