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

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

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

相关推荐

不愿透露姓名的神秘牛友
07-01 11:47
点赞 评论 收藏
分享
05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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