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

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

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

终于写对了。

思路:

1.先放框架

结果列先起好别名(题目难度、准确率)。

连接表别名(直接小写字母开头),根据哪列连接(on xxx),什么连接方式(inner join)

限定条件(where "浙江大学")

分组(题目难度)

排序(准确率)

2.具体获得

准确率——(正确题目)/(题目总数)

正确题目——使用if函数,result中right为1就是正确的

avg(if(qpd.result='right', 1, 0)) as correct_rate

sum(if(qpd.result='right', 1, 0)) / count(qpd.question_id) as correct_rate

count(if(qpd.result='right', 1, null)) / count(qpd.question_id) as correct_rate

最终答案

select 
    difficult_level,
    sum(if(qpd.result="right", 1, 0))/count(qd.question_id) as correct_rate
from user_profile as up
inner join question_practice_detail as qpd
on up.device_id = qpd.device_id
inner join question_detail as qd
on qpd.question_id = qd.question_id
where
up.university = "浙江大学"
group by qd.difficult_level
order by correct_rate
【牛客&赛文X】春招冲刺 文章被收录于专栏

仅作记录。

全部评论

相关推荐

01-24 12:50
门头沟学院 C++
投票
菜狗二号:还有啥想的 指定国有行啊,去了就开始幸福美满的生活了,选华子不是折腾自己么,最终财富积累度是差不多的,但是幸福指数是相差甚远的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务