题解 | #浙大不同难度题目的正确率#

浙大不同难度题目的正确率

https://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c

select t2.difficult_level,
round(sum(case when t1.result='right' then 1 else 0 end) 
      / count(t1.device_id),4) as correct_rate
from user_profile t
inner join question_practice_detail t1 on t.device_id = t1.device_id
inner join question_detail t2 on t1.question_id = t2.question_id
where t.university = '浙江大学' 
group by t2.difficult_level 
order by correct_rate

这个题首先想到的是多表链接,主要是把信息集合起来

然后根据顺序,使用where对大学进行限制

分组后就是求正确率了,这里使用了case when加聚合函数来求正确的题目数量。这个点是非常常用

全部评论

相关推荐

03-16 11:07
南开大学 Java
牛马人的牛马人生:快手卡实习经历的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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