题解 | 统计商家不同会员每日访问人次及访问人数

统计商家不同会员每日访问人次及访问人数

https://www.nowcoder.com/practice/0017dc22426b495889da3304dcf254d1

with t1 as (
select ub.vip,count(*) as visit_nums  from visit_tb
as vb 
left join uservip_tb
as ub 
on vb.user_id=ub.user_id
group by ub.vip),
t2 as (
select ub.vip,count(distinct vb.user_id) as visit_users  from visit_tb
as vb 
left join uservip_tb
as ub 
on vb.user_id=ub.user_id
group by ub.vip)
select t1.vip ,visit_nums,visit_users
from t1 
left join t2
on t1.vip=t2.vip
order by visit_nums desc ,visit_users desc
;

全部评论

相关推荐

牛至超人:把哈工大,再加大加粗,看见闪闪发光的哈工大字样,面试官直接流口水
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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