一旦学会窗口函数,突然有种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