题解 | 浙大不同难度题目的正确率

浙大不同难度题目的正确率

https://www.nowcoder.com/practice/d8a4f7b1ded04948b5435a45f03ead8c

 #先将每道题匹配上他的难易程度
# select p.*,q.difficult_level from  question_practice_detail as p left join  question_detail as q using(question_id)
#过滤出为浙江大学的学生,在对其做题难易程度进行分组。
#计算正确和错误题目的正确率,可以使用case语句,正确为1,错误为0.在使用sum()函数进行统计即可。

select
    difficult_level,
    sum(
        case
            when a.result = 'right' then 1
            else 0
        end
    ) / count(a.result) as correct_rate
from
    user_profile u
    join (
        select
            p.*,
            q.difficult_level
        from
            question_practice_detail as p
            left join question_detail as q using (question_id)
    ) as a using (device_id)
where
    u.university = '浙江大学'
group by
    a.difficult_level
order by
    correct_rate

全部评论

相关推荐

01-30 09:45
燕山大学 Java
喵_coding:这种直接跑就完事了 哪有毕业了才签合同 任何offer和三方都没有的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务