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

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

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

相关推荐

不愿透露姓名的神秘牛友
06-27 18:00
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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