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

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

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

select
 difficult_level,
 avg(case when qpd.result='right' then 1 else 0 end) as correct_rate
#  对result进行统计平均数,如果result为right则记作1,否则记为0,这样就可以用AVG函数来统计正确率
#  为了防止结果中有难度为None的结果,需要在order by前加一句 having qd.difficult_level != 'None'
from user_profile up
left join question_practice_detail qpd on up.device_id=qpd.device_id
left join question_detail qd on qpd.question_id=qd.question_id
# 利用相同键将三个表连接起来
where university='浙江大学'
# 浙江大学的学生
group by difficult_level
# 按难度分组
having qd.difficult_level != 'None'
# 为了防止因为左连接导致可能存在部分difficult_level为空的情况,需要把空的difficu_level去掉
order by correct_rate;

全部评论

相关推荐

03-16 13:56
湖南大学 C++
牛客872108596号:到现在没消息是挂了吗查看图片
点赞 评论 收藏
分享
爱喝奶茶的垂耳兔拥抱太阳:感觉项目和实习没有技术亮点和难点,单纯说了自己干了啥
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务