SELECT grade
FROM
    (
    SELECT grade,
           SUM(number) OVER(ORDER BY grade) AS rk1,#累计求和正序排序
           SUM(number) OVER(ORDER BY grade DESC) AS rk2,#累计求和倒序排序
           SUM(number) OVER() AS total #求人数的最大值
    FROM class_grade
    ORDER BY grade
    ) AS t
WHERE rk1 >= total/2
AND rk2 >= total/2
ORDER BY grade