select t2.difficult_level,
round(sum(case when t1.result='right' then 1 else 0 end) 
      / count(t1.device_id),4) as correct_rate
from user_profile t
inner join question_practice_detail t1 on t.device_id = t1.device_id
inner join question_detail t2 on t1.question_id = t2.question_id
where t.university = '浙江大学' 
group by t2.difficult_level 
order by correct_rate

这个题首先想到的是多表链接,主要是把信息集合起来

然后根据顺序,使用where对大学进行限制

分组后就是求正确率了,这里使用了case when加聚合函数来求正确的题目数量。这个点是非常常用