update 等级表 set 等级 =
(case when 用户ID in (select top 10 percent 用户ID from 等级表 order by 分数 desc) then '10%优' when 用户ID in (select top 30 percent 用户ID from 等级表 order by 分数 desc)
and 用户ID not in (select top 10 percent 用户ID from 等级表 order by 分数 desc) then '20%良' when 用户ID in (select top 90 percent 用户ID from 等级表 order by 分数 desc)
and 用户ID not in (select top 30 percent 用户ID from 等级表 order by 分数 desc) then '60%合格' else '10%不合格'
end
)
(case when 用户ID in (select top 10 percent 用户ID from 等级表 order by 分数 desc) then '10%优' when 用户ID in (select top 30 percent 用户ID from 等级表 order by 分数 desc)
and 用户ID not in (select top 10 percent 用户ID from 等级表 order by 分数 desc) then '20%良' when 用户ID in (select top 90 percent 用户ID from 等级表 order by 分数 desc)
and 用户ID not in (select top 30 percent 用户ID from 等级表 order by 分数 desc) then '60%合格' else '10%不合格'
end
)
(case when 用户ID in (select top 10 percent 用户ID from 等级表 order by 分数 desc) then '10%优' when 用户ID in (select top 30 percent 用户ID from 等级表 order by 分数 desc)
and 用户ID not in (select top 10 percent 用户ID from 等级表 order by 分数 desc) then '20%良' when 用户ID in (select top 90 percent 用户ID from 等级表 order by 分数 desc) then '60%合格' else '10%不合格'
end
)
(case when 用户ID in (select top 10 percent 用户ID
from 等级表 order by 分数 desc
) then '优'
when 用户ID in (select top 30 percent 用户ID
from 等级表 order by 分数 desc
) and 用户ID not in
(select top 10 percent 用户ID
from 等级表 order by 分数 desc
) then '良'
when 用户ID in (select top 90 percent 用户ID
from 等级表 order by 分数 desc
)and 用户ID not in
(select top 30 percent 用户ID
from 等级表 order by 分数desc
) then '合格' else '不合格'
end
)