题解 | #牛客的课程订单分析(四)#
牛客的课程订单分析(四)
http://www.nowcoder.com/practice/c93d2079282f4943a3771ca6fd081c23
MySQL整体结构全部使用
解体如下:
查询user_id,以及最小日期(date),sum()
select u.user_id,min(u.date),sum(case u.status when 'completed' then 1 else 0 end)as cnt from order_info u where u.product_name<>'JS'and u.date>'2025-10-15' group by u.user_id having cnt>=2 order by u.user_id;