题解 | #查找除复旦大学的用户信息#

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

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

代码1:

select
c.difficult_level,
count(if(result='right',a.question_id,null)) / count(a.question_id) as correct_rate
from

(select device_id,question_id,result
from question_practice_detail
)a

join

(select device_id
from user_profile
where university = '浙江大学'
)b
on a.device_id = b.device_id


left join
(
select
question_id,difficult_level
from question_detail
)c

on a.question_id = c.question_id
group by difficult_level
order by correct_rate

代码2:

select difficult_level,
(count(case when result='right' then 1 else null end)/count(*)) as correct_rate
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 difficult_level!='None'
//输出结果不能由none
order by correct_rate
全部评论

相关推荐

迟缓的斜杠青年巴比Q了:简历被投过的公司卖出去了,我前两天遇到过更离谱的,打电话来问我有没有意向报班学Java学习,服了,还拿我学校一个学长在他们那报班学了之后干了华为OD当招牌
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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