题解 | 查询下订单用户访问次数?
查询下订单用户访问次数?
https://www.nowcoder.com/practice/32bc1e0fce2343ad934b76a025e09fc5
select
v.user_id,
count(v.info_id) as visit_nums
from
visit_tb v
join (
select distinct
user_id
from
order_tb o
where
date(o.order_time) = '2022-09-02'
) o on v.user_id = o.user_id
where
date(leave_time) = '2022-09-02'
group by
user_id
order by
visit_nums desc;
已下单的用户,同一天内可能多次购买,需要DISTINCT筛选
