牛客的课程订单分析(七)

牛客的课程订单分析(七)

http://www.nowcoder.com/questionTerminal/d6f4a37f966145da8900ba9edcc4c068

select source,count(source) as cnt
from 
(select o.id,case c.id when 1 then "PC"
                      when 2 then "Android"
                      when 3 then "IOS"
                      when 4 then "H5"
                      else "GroupBuy"
            end as source
from order_info o
left join client c
on o.client_id=c.id
where o.date>"2025-10-15"
and o.product_name in ("C++","Python","Java")
and o.status='completed'
and o.user_id in (select user_id from
                 (select id, user_id ,row_number() over (partition by user_id order by id)rr 
                  from order_info
                  where status='completed'
                  and product_name in ("C++","Python","Java"))r
                  where r.rr>=2)
)a
group by source
order by source
全部评论
你这`source`的子查询方式是有问题, 用user_id枚举,如果是有十万条呢?
点赞 回复 分享
发布于 2021-04-14 22:47

相关推荐

预计下个星期就能开奖吧,哪位老哥来给个准信
华孝子爱信等:对接人上周说的是这周
投递华为等公司10个岗位 >
点赞 评论 收藏
分享
我是小红是我:学校换成中南
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务