题解 | #浙大不同难度题目的正确率#
浙大不同难度题目的正确率
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】春招冲刺 文章被收录于专栏
仅作记录。