思路:①两表连接,用非聚合的筛选条件完成数据筛选,形成tb1;②基于tb1,选出购买数量≥2的用户所在行数据即可。
with tb1 as(
select order_info.id as id, user_id, is_group_buy, name
from order_info left join client on order_info.client_id=client.id
where date>'2025-10-15' and status='completed' and product_name in ('C++','Java','Python')
)
select id, is_group_buy, name
from tb1
where user_id in
(select user_id from tb1 group by user_id having count(user_id)>=2)



京公网安备 11010502036488号