22,210
社区成员
发帖
与我相关
我的任务
分享
with temp as
(
select ID, 成绩,名次=ROW_NUMBER()OVER(PARTITION BY 成绩 ORDER BY 成绩 desc)
FROM 表格
)
declare @count int
select @count=count(1) from 表格
select ID, 成绩, 等级 = (case when 名次 between 1 and 10 then 'A'
when 名次 between @count-9 and @count then 'C'
else 'B')
from temp