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

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

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

select
    qd.difficult_level,
    sum(if (q.result = 'right', 1, 0)) / count(q.question_id) as correct_rate
from
    user_profile u
    left join question_practice_detail q on u.device_id = q.device_id
    left join question_detail qd on q.question_id = qd.question_id
where
    u.university = '浙江大学'
group by
    qd.difficult_level
having
    qd.difficult_level != 'None'
order by
    correct_rate
  1. 先确定连表条件-device_id 和 question_id
  2. 进一步通过where 只需‘浙江大学’条件
  3. 按难度进行分组
  4. 通过sum函数和count函数运算获取正确率
  5. 注意难度表中有为none的数据,需要在having过滤
全部评论

相关推荐

牛客765689665号:没有实习是硬伤,央国企看学历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务