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

考试分数(四)

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

#中位数就要考虑job对应的数量的奇偶了

select
/*case 
    when mod(T1.num,2)=0 then num/2
    when mod(T1,num,2)<>0 then CEILING(T1.num)
end as start
#记错了语法,mod(除数,被除数)*/
T1.job1 as job,
case 
    when mod(T1.num,2)=0 then ROUND(T1.num/2,0)
    else CEILING(T1.num/2)
end as start
,case 
    when mod(T1.num,2)=0 then  ROUND(T1.num/2+1,0)
    else CEILING(T1.num/2)
end as end
from
(select
g.job as job1,
count(g.score) as num
from grade g
group by g.job) as T1
order by T1.job1

奇数,中位数[N/2]

偶数,中位数(N/2,N/2+1)

全部评论

相关推荐

一天代码十万三:这个学历有中大厂实习也是0面,没办法,斩杀线是这样的
点赞 评论 收藏
分享
天降大厂offer:你是我见过最美的牛客女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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