sql script

select grade
from (select grade, (select sum(number) from class_grade) as total_number,
      sum(number) over(order by grade) as up, sum(number) over(order by grade desc) as down
      from class_grade) tmp1
where up>=total_number/2 and down>=total_number/2
order by grade