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

这个排序是不是搞错了,得这么多排序条件才行。一直认为这种题目考排序就是逗霸,业务中极少要求多列排序的,Excel搞一下不比占用计算资源好多了。