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

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

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

  1. 第一次购买的日期辅助表
  2. 合计购买数量的辅助表
  3. 合并后筛选
with first_buy_date as (
select user_id,min(date) first_date from order_info
where status = 'completed' and 
product_name in ('C++','Python','Java') and 
date > '2025-10-15' group by user_id),
  
buy_count as (
select user_id,count(date) buy_count from order_info
where status = 'completed' and 
product_name in ('C++','Python','Java') and 
date > '2025-10-15' group by user_id)
- 
select a.user_id,first_date,buy_count from
buy_count a left join first_buy_date b
on a.user_id == b.user_id
where buy_count>=2 
order by a.user_id

全部评论

相关推荐

弦五Strings:他之所以会举报你代课是因为在这种人眼里正常上课就是正义代课就是邪恶,典型二极管思维,处理方法就是私下沟通,你就说你自己家里经济困难或者家里父母生病什么之类的,需要去打工挣钱,用尽孝的正义对冲他认为的上课的正义,他可能就妥协了。
我的实习日记
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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