题解 | #牛客的课程订单分析(六)#
牛客的课程订单分析(六)
http://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f
select c.id,c.is_group_buy,client.name
from
(
//子查询,找出符合要求的订单
select *
from order_info a
where a.user_id in
( //子查询,找出VIP客户
select b.user_id
from order_info b
where b.date>'2025-10-15'
and b.status='completed'
and b.product_name in ('C++','Python','Java')
group by b.user_id
having count(b.user_id)>=2
)
and a.date>'2025-10-15'
and a.status='completed'
and a.product_name in ('C++','Python','Java')
)c left join client //将符合要求的订单与客户端信息表进行左连接
on c.client_id = client.id
order by c.id asc;