题解 | 查询连续入住多晚的客户信息?
查询连续入住多晚的客户信息?
https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd
with t as (select c.user_id, c.room_id, c.checkin_time, c.checkout_time, g.room_type from checkin_tb c left join guestroom_tb g on c.room_id = g.room_id ) select user_id, room_id, room_type, datediff(substring(checkout_time,1,10), substring(checkin_time,1,10)) as days from t where datediff(substring(checkout_time,1,10), substring(checkin_time,1,10)) >= 2 order by days asc, room_id asc, user_id desc
查看14道真题和解析