题解 | #浙大不同难度题目的正确率#
浙大不同难度题目的正确率
https://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c
运营想要了解浙江大学的用户在不同难度题目下答题的正确率情况,请取出相应数据,并按照准确率升序输出。
- 浙江大学用户 可以得出where university = '浙江
- 在不同难度题目下,可以知道需要按照题目难度分组查询,且需要连接查询
- 分组查询 group by question_detail.difficult_level
- 连接查询 from user_profile user
right join question_practice_detail qus on user.device_id = qus.device_id
left join question_detail dif on qus.question_id = dif.question_id
- 正确率result为right/总数
- 按照准确率升序输出,最后order by准确率 asc(可写可不写)
select dif.difficult_level, sum(if(qus.result = 'right',1,0))/count(*) as correct_rate from user_profile user right join question_practice_detail qus on user.device_id = qus.device_id left join question_detail dif on qus.question_id = dif.question_id where user.university = '浙江大学' group by dif.difficult_level order by correct_rate asc;