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

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

https://www.nowcoder.com/practice/348afda488554ceb922efd2f3effc427

用临时表做很简单 但是牛客网报错 mysql上结果是对的
create temporary table first_buy
select user_id,min(date)as first_buy_date,count(id)as order_number
from order_info
where user_id in (select user_id
from order_info
where date>'2025-10-15'
and status= 'completed'
and product_name in('C++','Java','Python')
group by user_id
having count(id)>=2)
and date>'2025-10-15'
and status= 'completed'
and product_name in('C++','Java','Python')
group by user_id;

select first_buy.user_id,first_buy.first_buy_date,min(order_info.date)as second_buy_date,first_buy.order_number
from first_buy
join order_info
on first_buy.user_id=order_info.user_id
where first_buy.first_buy_date <order_info.date
group by 1,2,4;
全部评论

相关推荐

10-30 22:18
已编辑
毛坦厂中学 C++
点赞 评论 收藏
分享
11-02 09:49
已编辑
货拉拉_测试(实习员工)
热爱生活的仰泳鲈鱼求你们别卷了:没事楼主,有反转查看图片
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务