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

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

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

相关推荐

这不纯纯作弊了吗😢😢😢
编程界菜鸡:信这个的这辈子有了,这智商你靠啥都没用
点赞 评论 收藏
分享
每晚夜里独自颤抖:要求太多的没必要理
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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