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

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

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;
全部评论

相关推荐

11-15 17:19
湖南大学 Java
成果成果成果果:这是哪个公司的hr,这么离谱吗,我没见过用性别卡技术岗的,身边女性同学拿大厂offer的比比皆是
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务