题解 | #浙大不同难度题目的正确率#
浙大不同难度题目的正确率
http://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c
解题思路:
1.联接三表,筛选university为‘浙江大学’的表作为 date1;
2.正确率的理解:结果为right的求和/所有结果的次数;
3.从date1中查询题目要求字段,及难度、正确率;
4.group by 难度,并按照正确率升序排列
代码为:
select date1.difficult_level,
sum(if(date1.result='right',1,0))/ count(date1.result) as correct_rate
from
(select u.device_id,q.question_id,q.result result,qd.difficult_level difficult_level
from question_practice_detail q
join user_profile u on (q.device_id =u.device_id )
join question_detail qd on (qd.question_id=q.question_id )
where u.university='浙江大学')
as date1
group by date1.difficult_level
order by correct_rate
sum(if(date1.result='right',1,0))/ count(date1.result) as correct_rate
from
(select u.device_id,q.question_id,q.result result,qd.difficult_level difficult_level
from question_practice_detail q
join user_profile u on (q.device_id =u.device_id )
join question_detail qd on (qd.question_id=q.question_id )
where u.university='浙江大学')
as date1
group by date1.difficult_level
order by correct_rate