题解 | 查询下订单用户访问次数?

查询下订单用户访问次数?

https://www.nowcoder.com/practice/32bc1e0fce2343ad934b76a025e09fc5

可不用表合并的方法。将order_tb中筛选出的用户作为在visit_tb中查询的where条件。

※date()函数可直接提取时间的'年-月-日'。

select user_id,count(*) visit_nums
from visit_tb
where user_id in(
    select distinct user_id
    from order_tb
    where date_format(order_time,'%Y-%m-%d')='2022-09-02'
)
and date_format(visit_time,'%Y-%m-%d')='2022-09-02'
and date_format(leave_time,'%Y-%m-%d')='2022-09-02'
group by user_id
order by visit_nums desc

全部评论

相关推荐

05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求职打法:注意把武大标粗标大 本地你俩不是乱杀
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务