题解 | #查询连续入住多晚的客户信息?#

查询连续入住多晚的客户信息?

https://www.nowcoder.com/practice/5b4018c47dfd401d87a5afb5ebf35dfd

with room_checkin as(
select user_id,
       a.room_id as room_id,
       room_type,
       datediff(date(checkout_time),date(checkin_time)) as days
from guestroom_tb a right join checkin_tb b on a.room_id=b.room_id)


select user_id,
room_id,
room_type,
days
from room_checkin
where days>1
order by days,room_id,user_id desc

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务