题解 | #连续两次作答试卷的最大时间窗#

连续两次作答试卷的最大时间窗

http://www.nowcoder.com/practice/9dcc0eebb8394e79ada1d4d4e979d73c

1.首先计算2021年至少有两天作答过试卷的人,确定好uid(下划线部分)
2.其次分别利用窗口函数计算days_window及avg_exam_cnt,
最后讲两张表合并即可
3.注意做了几张试卷并没有说要做完,因此计算avg_exam_cnt时需要用start_time进行计数

select a.uid,days_window,round(days_window*cd,2) as avg_exam_cnt from
(select uid,max(w)+1 as days_window from
(select uid,datediff(submit_time,pre) as w
from
(select uid,submit_time,LAG(submit_time,1) over(partition by uid order by submit_time) as pre from
exam_record where year(submit_time)=2021 and uid in
(select uid from exam_record where year(submit_time)=2021
group by uid having count(distinct date_format(submit_time,'%m%d'))>=2)) a) b group by uid
) a
join
(select uid,count(start_time)/(datediff(max(start_time),min(start_time))+1) as cd
from exam_record where year(start_time)=2021 and uid in
(select uid from exam_record where year(submit_time)=2021
group by uid having count(distinct date_format(submit_time,'%m%d'))>=2) group by uid
) b
on a.uid=b.uid order by days_window desc,avg_exam_cnt desc
    

全部评论

相关推荐

在下uptown:山东的哥们得好好回答 第一问题,专业技能太少了,现在写的大部分都是模型迭代过渡期的技术栈,说白了今天用明天可能就不用,多补一些看家的本事 第二个问题,项目偏学术学习体现不出工程能力,deepresearch核心在于模型自我反馈自我纠正,没体现出来,RAG本身在落地应用上就是个伪命题。 再有就是,有实习经历可以弥补学历不足,建议放到学历下面,别人筛简历可能第一眼觉得学校不过关,但第二眼有实习经历,就给你面试了,藏到后面可能就没有第二眼了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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