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

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

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

select table_a.*,client.name from  
(select * from order_info where user_id in (select user_id from order_info where date>'2025-10-15' and status='completed' and product_name in('C++','Java','Python')
group by user_id having count(user_id)>1) and date>'2025-10-15' and status='completed' and product_name in('C++','Java','Python'))
table_a  
left join client
on table_a.client_id=client.id
来获取所有的信息,然后就是将client_id与is_group_buy双聚合,再通过is_group_buy来判断,如下:
select if(is_group_buy='Yes','GroupBuy',name) as source,count(is_group_buy) as cnt from 
(select table_a.*,client.name from  
(select * from order_info where user_id in (select user_id from order_info where date>'2025-10-15' and status='completed' and product_name in('C++','Java','Python')
group by user_id having count(user_id)>1) and date>'2025-10-15' and status='completed' and product_name in('C++','Java','Python'))
table_a  
left join client
on table_a.client_id=client.id
)first_filter

group by client_id,is_group_buy
order by source
;


全部评论

相关推荐

06-26 15:33
青岛工学院 Java
积极的秋田犬要冲国企:他现在邀请我明天面试
点赞 评论 收藏
分享
zYvv:双一流加大加粗再标红,然后广投。主要是获奖荣誉不够,建议开始不用追求大厂,去别的厂子刷下实习。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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