declare @t Table (学号 varchar(10),分数 varchar(10))
insert into @t
select '1','50'
union all select '2','56'
union all select '3','87'
union all select '4','40'
union all select '5','23'
select 学号,分数 into #t from @t
select 分数,identity(int,1,1)as 名次 into #t1 from @t order by 分数 desc
select #t.学号,#t.分数,#t1.名次 from #t left join #t1 on #t1.分数=#t.分数