题解 | #牛客的课程订单分析(五)#可读性好就是麻烦

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

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

with first as  (
  select user_id,min(date) first_date,count(*) cnt
  from order_info
  where date>='2025-10-15'
  and status='completed'
  and product_name in ('C++','Java','Python')
  group by user_id
  having count(*)>=2
),
second as (
SELECT user_id,date second_date
from (
  select *
  ,row_number()over(partition by user_id order by date) posn
  from order_info
  where date>='2025-10-15'
  and status='completed'
  and product_name in ('C++','Java','Python')
) as t
where posn=2
)
SELECT  first.user_id,first.first_date,second.second_date,first.cnt
from first 
inner join second
on first.user_id=second.user_id
order by first.user_id
全部评论

相关推荐

04-03 09:32
已编辑
华南农业大学 golang
我的代码出BUG了:"晚点发个邮件调整一下时间",你收到新的邮件没,如果没有收到新的邮件,那就需要进入面试链接留痕,否则系统会判定你迟到
点赞 评论 收藏
分享
最喜欢秋天的火龙果很...:第一份工作一定要往大的去,工资低点没事。后面换工作会更好找,即使你去小公司,你也不可能不会换工作的。所以找大的去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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