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

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

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
;


全部评论

相关推荐

WillingLing:查看图片
点赞 评论 收藏
分享
牛客ID:561366855:期望薪资多少?难以相信这简历找不到工作。说明二本电子信息专业想对口就业非常难。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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