题解 | #各用户等级的不同得分表现占比#

各用户等级的不同得分表现占比

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

select level,score_grade,round(num2/num1,3) as ratio
from (
			select level,score_grade,
						 count(score_grade) as num2
			from (
						select level,
									 case when score<60 then '差'
												when score>=60 and score<75 then '中'
												when score>=75 and score<90 then '良'
												when score>=90 then '优'
												end as score_grade
						from exam_record
						left join user_info using(uid)
						where submit_time is not null
						) as t
			group by level,score_grade
			) as t1
left join (
		select level,count(submit_time) as num1
		from exam_record
		left join user_info using(uid)
		group by level) as t2 using(level)
order by level desc,ratio desc
全部评论

相关推荐

点赞 评论 收藏
分享
10-31 20:07
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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