PERCENT_RANK()函数
PERCENT_RANK()函数用于将每行按照(rank - 1) / (rows - 1)进行计算,用以求MySQL中前百分之N问题。其中,rank为RANK()函数产生的序号,rows为当前窗口的记录总行数
PERCENT_RANK()函数返回介于 0 和 1 之间的小数值
selectstudent_id, class_id, score,percent_rank() over (partition by class_id order by score desc ) as p_rn
from tb_grade;