题解 | 查询下订单用户访问次数?
SELECT user_id,COUNT(user_id) AS visit_nums FROM visit_tb WHERE user_id IN (SELECT user_id FROM order_tb WHERE DATE(order_time) = "2022-09-02") AND DATE(visit_time) = "2022-09-02" #AND DATE(leave_time) = "2022-09-02" #存在一条数据错误,离开时间早于访问时间 GROUP BY user_id ORDER BY visit_nums DESC
有一条数据存在问题,离开时间早于访问时间,要注意