题解 | #牛客的课程订单分析(七)#

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

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

这一道题就是上一道题的扩展,理解了上一道题,就很容易做出来。

但是注意不要被上一步中cnt迷惑。

select source, count(source) as sum_cnt
from
(select 
(case when is_group_buy = 'Yes' then 'GroupBuy'
	 when is_group_buy ='No' then name end) as source,
     cnt
from client
right outer join
(select id, client_id, count(1) over (partition by user_id) as cnt, is_group_buy
from order_info
where date > '2025-10-15'
and status = 'completed'
and product_name in ('C++','Python','Java')) as b
on client.id = b.client_id
where cnt >= 2
order by b.id) as c
group by source
order by source;
MySQL试题答案解析 文章被收录于专栏

MySQL在线编程重点试题解析

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 17:33
点赞 评论 收藏
分享
鬼迹人途:你去投一投尚游游戏,服务器一面,第一个图算法,做完了给你一个策略题,你给出方案他就提出低概率问题,答不上当场给你挂
点赞 评论 收藏
分享
面试了几家,全程问项目,八股一点都不问,可惜准备了这么久
独角仙梦境:现在感觉问八股像是中场休息一样的,问几个八股放松一下再上强度
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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