select name,
       score,
       排名=(select count(1) from tb where score>a.score) 
from tb a

解决方案 »

  1.   

    select name,
           score,
           排名=(select count(1) from tb where score>=a.score) 
    from tb a
      

  2.   

    declare @t table([name] char(10),score int)insert into @t select 'song',100 union all
                   select 'ttt',55 union all
                   select '333',67 union all
                   select 'rrty',87 union all
                   select 'yyy',90select [name],score,(select count(*)+1 from @t where score>a.score) as mingci from @t a
      

  3.   

    select *,1+(select count(*) from course b where score<a.score) as 排名
    from course a
    order by score
      

  4.   

    select *,1+(select count(*) from course b where a.score<score) as 排名
    from course a
    order by score desc
      

  5.   

    不对吧,应该是select *,1+(select count(*) from course b where a.score>score) as 排名
    from course a
    order by score desc