题解 | #浙大不同难度题目的正确率#
浙大不同难度题目的正确率
https://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c
select difficult_level, 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 from user_profile as up join question_practice_detail as qpd on up.device_id=qpd.device_id join question_detail as qd on qpd.question_id=qd.question_id where university='浙江大学' group by difficult_level #这样group by difficult_level having university='浙江大学'的话会编译错误出错,应当用下面的: #group by university,difficult_level having university="浙江大学" order by correct_rate