知识点

  1. 和上一题一样加上一行计数的列统计筛选条件后进行计数
  2. 最后表格筛选条件就是计数大于等于的行

代码

select g.id, g.user_id, g.product_name, g.status, g.client_id, g.date
from (
      select *, count(*) over(partition by user_id) as c
      from order_info
      where date > '2025-10-15'
      and status = 'completed'
      and product_name in ('C++', 'Java', 'Python')
      ) as g
where g.c >= 2
order by g.id