题解 | #牛客的课程订单分析(六)#
牛客的课程订单分析(六)
http://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f
SELECT o.id, o.is_group_buy, CASE WHEN o.client_id = 0 THEN c.name = NULL ELSE c.name END AS client_name FROM order_info o LEFT JOIN CLIENT c ON o.client_id = c.id WHERE o.date >= '2025-10-15' AND o.status = 'completed' AND o.product_name IN ('C++', 'Java', 'Python') AND o.user_id IN (SELECT user_id FROM (SELECT user_id, COUNT(*) cnt FROM order_info WHERE STATUS = 'completed' AND DATE >= '2025-10-15' AND product_name IN ('C++', 'Java', 'Python') GROUP BY user_id) AS user_id_cnt WHERE cnt >= 2) ;