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

SELECT t1.user_id, t1.room_id, t2.room_type,
       DATEDIFF(t1.checkout_time, t1.checkin_time) AS days
FROM checkin_tb AS t1
LEFT JOIN guestroom_tb AS t2
ON t1.room_id = t2.room_id
WHERE t1.checkin_time > '2022-06-12'
HAVING days >=2 
ORDER BY days,t1.room_id,t1.user_id desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务