题解 | #牛客的课程订单分析(六)#

牛客的课程订单分析(六)

http://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f

根据题意,先把购买成功次数在两次以上的用户筛选出来,在通过join和原表连接,将没有成功次数在两次以上的用户剔除,在把客户端表left join 连接起来,最后三表连接后,在写一遍约束条件即可
select o.id, o.is_group_buy, client.name
from
order_info o
join
    (select user_id
    from order_info
    where date > '2025-10-15'
    and product_name in ('C++','Java','Python')
    and status = 'completed'
    group by user_id
    having count(user_id)>=2
    ) a
on o.user_id=a.user_id
left join
client
on o.client_id=client.id
where o.date > '2025-10-15'
and o.product_name in ('C++','Java','Python')
and o.status = 'completed'
order by o.id;

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务