题解 | #试卷完成数同比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

全部评论

相关推荐

oppo 应用软开 22*15+0.5*12
拿到了ssp完美:真的坎坷,但是你至少拿到这么多offer了!
点赞 评论 收藏
分享
头像
11-09 12:17
清华大学 C++
out11Man:小丑罢了,不用理会
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务