题解 | 查询连续入住多晚的客户信息?
查询连续入住多晚的客户信息?
https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd
select
ct.user_id,
ct.room_id,
gt.room_type,
(day(ct.checkout_time) - day(checkin_time)) as days
from checkin_tb ct
inner join guestroom_tb gt
on gt.room_id = ct.room_id
having days >= 2
order by days asc ,ct.room_id asc , ct.user_id desc
