浙江大学不同难度题目正确率
分析: 浙江大学, 不同难度, 正确率;
- 题目只需要浙江大学的, 所以可以连表后直接在where中进行过滤,
- 不同难度正确率,根据难度分组, 该难度答对的题数/该难度总题数即可
- if(qpd.result='right', 1, 0)这样其实代码更简洁, 但是个人更习惯用case when 语法
select qd.difficult_level,
sum(case when qpd.result = 'right' then 1 else 0 end) / count(1) as correct_rate
from question_practice_detail qpd
join user_profile up on qpd.device_id=up.device_id
join question_detail qd on qd.question_id=qpd.question_id
where up.university='浙江大学'
group by qd.difficult_level
order by correct_rate