题解 | #考试分数(四)#
考试分数(四)
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)