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

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

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

select
    qd.difficult_level,
    round(sum(correct_q) / sum(all_q), 4) as correct_rate -- 正确率=正确题目数量/所有题目数量
from
    (
        select
            qpd1.question_id,
            count(
                case
                    when qpd1.result = 'right' then qpd1.device_id
                    else null
                end
            ) correct_q, -- 正确题目数量
            count(qpd1.id) all_q -- 所有题目数量
        from
            (
                select
                    qpd.device_id,
                    qpd.question_id,
                    qpd.result,
                    up.university,
                    qpd.id
                from
                    question_practice_detail qpd
                    left join user_profile up on qpd.device_id = up.device_id
                where
                    up.university = '浙江大学' 
            ) qpd1 -- 限制计算范围为浙江大学
        group by
            question_id
    ) qpd2
    left join question_detail qd on qpd2.question_id = qd.question_id
group by 
    qd.difficult_level
order by correct_rate asc 

全部评论

相关推荐

简历求拷打,海投简历发过去就已读不回了求大佬们指点
程序员牛肉:基本不能了,估计你得放弃秋招,九月份找实习之后明年的春招开始正式找工作
点赞 评论 收藏
分享
有担当的灰太狼又在摸鱼:零帧起手查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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