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

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

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

/*select difficult_level,sum(if(result='wrong',0,1))/count(qpd.question_id)
from user_profile u
left outer join question_practice_detail qpd
on u.device_id = qpd.device_id
left outer join question_detail q
on qpd.question_id = q.question_id
where university = '浙江大学'
group by difficult_level*/
#上面的做法是错误的,一开始u表和qpd不应该是u表左连接qpd表,因为我们要统计的数据,其数量来源实质上来源于qpd表,u表和q表分别起到补充“大学 ”信息以及“难度”信息而已。如果链接错误,则在后面count的时候会出现none值。

select difficult_level ,sum(if(result='right',1,0))/count(qpd.result) as correct_rate
from user_profile u
right outer join question_practice_detail qpd
on u.device_id = qpd.device_id
left outer join question_detail q
on qpd.question_id = q.question_id
where university = '浙江大学'
group by difficult_level
order by correct_rate

全部评论

相关推荐

程序员小白条:学历和简历问题,你想走开发,现在很难的啦,尤其后端方向很难走,前端、测开,都会好很多,另外要等8月底和9月初去投日常
点赞 评论 收藏
分享
头像
07-26 14:05
门头沟学院 Java
欧贺桥:哈哈哈哈哈笑死我了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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