可以在数据库里计算好,其中rownum是给每行一个编号,row_total表示总行号
select case
when round(row_num/row_total,4)<=0.02 then 'A+'
when round(row_num/row_total,4)<=0.05 then 'A'
else '其他等级' end,其他列
from(
select rownum row_num,其他列,count(1) over(partition by 1) row_total
from 表 order by 排序列)