题解 | 查询连续入住多晚的客户信息?
查询连续入住多晚的客户信息?
https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd
select ct.user_id,
gt. room_id,
gt.room_type,
datediff(checkout_time,checkin_time) days
from guestroom_tb as gt
inner join checkin_tb as ct on gt.room_id=ct.room_id
where date(checkin_time)='2022-6-12'and datediff(checkout_time,checkin_time)>=2
order by days ,room_id,user_id desc
datediff函数用于获取两个日期相差的天数
查看21道真题和解析
