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

这道题的话我本是这么做的 虽然看上去很麻烦 但是为什么计算出来是1呢

描述

题目:
现在运营想要了解江大学的用户在不同难度题目下答题的正确率情况,请取出相应数据,并按照准确率升序输出。



#浙大的用户
(select *
from user_profile
where university='浙江大学') as tt
#答题正确率为 正确数/总答题数 或总题数
#不同难度 group by difficult_level

#提取出浙大的正确数
(select question_id
from question_practice_detail,user_profile
where user_profile.device_id=question_practice_detail.device_id and university='浙江大学' and result='right') as pp
//完整代码
select difficult_level,count(pp.question_id)/count(tt.question_id) as correct_rate
from user_profile,
(select question_id
from user_profile,question_practice_detail
where user_profile.device_id=question_practice_detail.device_id  and university='浙江大学'
) as tt,
(select question_id
from question_practice_detail,user_profile
where user_profile.device_id=question_practice_detail.device_id 
 and university='浙江大学' and result='right') as pp
 where question_detail.question_id=tt.question_id
 group by difficult_level
 order by difficult_level asc;
#MySQL##笔记##考研#
全部评论
牛呀,牛呀
点赞 回复 分享
发布于 2022-04-18 20:48

相关推荐

05-22 17:07
已编辑
门头沟学院 Java
程序员牛肉:都啥时候了还jb打蓝桥杯呢,有限找实习。
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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