题解 | #牛客的课程订单分析(七)#
牛客的课程订单分析(七)
http://www.nowcoder.com/practice/d6f4a37f966145da8900ba9edcc4c068
SELECT source, count(*) as cnt FROM
(SELECT
case when client_id = 0 then 'GroupBuy' else name end as source
from order_info oi
left JOIN client c
ON oi.client_id = c.id
where date > '2025-10-15' and status = 'completed'
and product_name IN ('C++','Java','Python')
and 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) >= 2)) a
GROUP BY source
order by source