题解 | #SQL35 浙大不同难度题目的正确率#
浙大不同难度题目的正确率
http://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c
SELECT
qd.difficult_level,
SUM(IF(qpd.result='right',1,0)) / COUNT(*) AS correct_rate
FROM(
SELECT
device_id
FROM
user_profile
WHERE
university='浙江大学'
) AS u
JOIN
question_practice_detail AS qpd
ON
u.device_id=qpd.device_id
JOIN
question_detail AS qd
ON qpd.question_id=qd.question_id
GROUP BY
qd.difficult_level
ORDER BY
correct_rate