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

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

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在线编程重点试题解析

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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