题解 | #考试分数(四)#

考试分数(四)

http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c

先分组聚合函数求出各job的分数个数num, 再逻辑函数判断出num为奇或为偶,连接各自计算公式

select job,
case when mod(num,2)=1 then round((num+1)/2) else round(num/2) end as start,
case when mod(num,2)=0 then round(num/2+1) else round((num+1)/2) end as end
from (select job,count(id) num from grade group by job) t
order by job;

全部评论

相关推荐

昨天 14:55
门头沟学院 Java
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
评论
8
收藏
分享

创作者周榜

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