select a.id,a.姓名,a.成绩,count(*) as 名次,IIF(count(*)<=10,'好',IIF(count(*)<=20,'良','差'))
from [user] a inner join [user] b on a.成绩<=b.成绩
group by a.id,a.姓名,a.成绩
order by a.成绩 desc
select a.id,a.姓名,a.成绩,count(*) as 名次,IIF(count(*)<=10,'好',IIF(count(*)<=20,'良','差')) as 分类
from [user] a inner join [user] b on a.成绩<=b.成绩
where a.id=10
group by a.id,a.姓名,a.成绩
order by a.成绩 desc