题解 | #试卷完成数同比2020年的增长率及排名变化#

试卷完成数同比2020年的增长率及排名变化

https://www.nowcoder.com/practice/13415dff75784a57bedb6d195262be7b

select t1.tag,2020_cnt,2021_cnt,concat(round((2021_cnt-2020_cnt)/2020_cnt*100,1),'%') 'growth_rate',2020_rank,2021_rank, CAST(2021_rank as SIGNED) - CAST(2020_rank AS SIGNED) 'rank_delta'
from((select tag, count(score) '2021_cnt',rank()over(order by count(score) desc) '2021_rank'
from exam_record r left join examination_info i on r.exam_id = i.exam_id
where date_format(start_time,'%Y%m') between '202101' and '202106'
and submit_time is not null
group by tag) t1 inner join 
(
select tag, count(score) '2020_cnt',rank()over(order by count(score) desc) '2020_rank'
from exam_record r left join examination_info i on r.exam_id = i.exam_id
where date_format(start_time,'%Y%m') between '202001' and '202006'
and submit_time is not null
group by tag) t2 on t1.tag = t2.tag)
order by growth_rate desc,rank_delta desc

全部评论

相关推荐

小红书 后端选手 n*16*1.18+签字费期权
点赞 评论 收藏
分享
有趣的牛油果开挂了:最近这个阶段收到些杂七杂八的短信是真的烦
点赞 评论 收藏
分享
听说改名字就能收到offer哈:Radis写错了兄弟
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务