题解 | #最差是第几名(二)#
最差是第几名(二)
https://www.nowcoder.com/practice/165d88474d434597bcd2af8bf72b24f1
破题,不看提示硬控我五个小时,最后参考区间法做出
with median as ( select grade,number,he,add_up,med,lag(add_up)over(order by grade) la from (select grade,number,sum(number)over() he,sum(number)over(order by grade) add_up,sum(number)over()/2 med from class_grade) t1 ) select grade from median where med between la and add_up