题解 | #牛客的课程订单分析(三)#
牛客的课程订单分析(三)
https://www.nowcoder.com/practice/4ae8cff2505f4d7cb68fb0ec7cf80c57
一旦学会窗口函数,突然有种sql刷起来很无趣的感觉
select id, user_id, product_name, status, client_id, date from ( select id, user_id, product_name, status, client_id,date, sum(case when status ='completed' then 1 else 0 end) over (partition by user_id) as completed_cnt from order_info where date > '2025-10-15' and product_name in ('C++','Java','Python') and status = 'completed' ) t where t.completed_cnt >= 2 order by id asc