题解 | 浙大不同难度题目的正确率 (子查询和连接查询)
浙大不同难度题目的正确率
https://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c
这个是我一开始的思路,大概是子查询吧
我还看到了内连接:
SELECT t3.difficult_level as difficult_level,
sum(if(t1.result="right",1,0))/ COUNT(t1.result) as correct_rate
FROM user_profile t2
RIGHT JOIN question_practice_detail t1
ON (t2.device_id = t1.device_id)
LEFT JOIN question_detail t3
ON (t3.question_id = t1.question_id)
WHERE t2.university = "浙江大学"
GROUP BY t3.difficult_level
--大概就是直接把三个表连接起来,最后再筛选,在处理正确率方面都打差不差,好像也没有更好的方法
--这道题内外连接都是一样的,不存在说要找空值,不过很多人好像都喜欢这样用
查看1道真题和解析
