题解 | #牛客的课程订单分析(六)#
牛客的课程订单分析(六)
https://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f
SELECT a.id, a.is_group_buy, IF (a.is_group_buy = 'Yes', NULL, c.name) as cn FROM order_info a JOIN ( SELECT user_id FROM order_info WHERE status = 'completed' GROUP BY user_id HAVING count(1) >= 2 ) as uc ON a.user_id = uc.user_id LEFT JOIN client c ON a.client_id = c.id WHERE a.status = 'completed' AND a.product_name in('C++','Java','Python') ORDER BY a.id