参考大牛的解法,绝了
当某一数的正序和逆序累计均大于整个序列的数字个数的一半即为中位数
select grade from (select grade, (select sum(number) from class_grade) as total, sum(number)over(order by grade) a, -- 求正序 sum(number)over(order by grade desc) b -- 求逆序 from class_grade order by grade)t where a >= total/2 and b >= total/2 -- 正序逆序均大于整个数列数字个数的一半 order by grade;