题解 | 查询连续入住多晚的客户信息?
查询连续入住多晚的客户信息?
https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd
SELECT * FROM( SELECT t1.user_id, t1.room_id, t2.room_type, CEIL(TIMESTAMPDIFF(HOUR,checkin_time,checkout_time)/24) days FROM checkin_tb t1 LEFT JOIN guestroom_tb t2 ON t1.room_id = t2.room_id WHERE checkin_time > '2022-6-12' ORDER BY days,t1.room_id,t1.user_id DESC ) a WHERE a.days > 1