题解 | #查询连续入住多晚的客户信息?#
查询连续入住多晚的客户信息?
https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd
SELECT B.user_id, B.room_id, A.room_type, DATEDIFF (checkout_time, checkin_time) AS days FROM guestroom_tb A JOIN checkin_tb B ON A.room_id = B.room_id WHERE DATEDIFF (checkout_time, checkin_time) > 1 ORDER BY DATEDIFF (checkout_time, checkin_time)ASC,B.room_id ASC,B.user_id DESC