题解 | #查询连续入住多晚的客户信息?#
查询连续入住多晚的客户信息?
https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd
#计算日期需要+1,用timestampdiff函数 select user_id,room_id,room_type,timestampdiff(day,checkin_time,checkout_time)+1 as days from guestroom_tb join checkin_tb using(room_id) where date(checkin_time) >= '2022-06-12' and timestampdiff(day,checkin_time,checkout_time) > 0 order by 4,2,1 desc #就是这个排序,呆的不谈,题目不说,完全根据答案修改的