insert 成绩表 values (@姓名,@成绩)
select count(*) from 成绩表 where 成绩>@成绩

解决方案 »

  1.   

    不太明白你的意思。:)得到排名第一可以:select top 1 姓名,成绩from 表 order by 成绩 desc
      

  2.   

    insert 成绩表 values (@姓名,@成绩)
    select count(*) from 成绩表 where 成绩>=@成绩
      

  3.   

    insert into yourtable values ('王二', 80)
    select count(*) as 排名 from yourtable as A
     where 成绩 >= (select 成绩 from yourtable where 姓名 = '王二')
      

  4.   

    insert 成绩表 values (@姓名,@成绩)
    select count(*) from 成绩表 where 成绩>=@成绩
      

  5.   

    大家好像没有考虑并列的情况,例如:
    姓名  成绩  
    张三   23
    李四   50
    孙六   80
    这时加入王二(80分)时,返回王二的排名应该是并列第1因此,如果考虑并列的情况,应该做如下调整:declare @姓名 varchar(10),@成绩 int
    select @姓名='王二',@成绩=80insert 成绩 values (@姓名,@成绩)
    select count(distinct 成绩) from 成绩 where 成绩>=@成绩
      

  6.   

    insert 成绩表 values (@姓名,@成绩)
    select count(*) from 成绩表 where 成绩>=@成绩
    这个方法比较妙,学习。