题解 | #牛客的课程订单分析(二)#
牛客的课程订单分析(四)
http://www.nowcoder.com/practice/c93d2079282f4943a3771ca6fd081c23
sql分步计算
SELECT a.user_id, b.first_buy_date, a.cnt FROM ( SELECT user_id,COUNT(1) AS cnt FROM order_info WHERE date > '2025-10-15' AND status='completed' AND product_name IN('C++','Java','Python') GROUP BY user_id HAVING COUNT(1) >= 2 )a, ( SELECT min(date) AS first_buy_date, user_id FROM order_info WHERE date > '2025-10-15' AND status='completed' AND product_name IN('C++','Java','Python') GROUP BY user_id )b WHERE a.user_id = b.user_id ORDER BY a.user_id