如题

解决方案 »

  1.   

    select num = (select count(1) form table a where a.排序字段 < 排序字段 order by a.排序字段 ) from table
      

  2.   

    怎么增加 ?
    比如 我要在user表中找一个id 编号为10的用户,并得到以他的年龄为升序的记录中的排名?
      

  3.   

    select num = (select count(1) form table a where a.排序字段 < 排序字段 order by a.排序字段 ) from table 有错误 不能查询
      

  4.   

    create table test(id int,age int)
    insert test select 1,20
    union all select 2,36
    union all select 4,10
    union all select 10,25
    union all select 11,23
    union all select 6,38select bh=identity(int,1,1),* into # from testselect bh from # where id=10
    order by agedrop table test,#bh          
    ----------- 
    4
      

  5.   

    用临时表?
    我想的语句是 
    select count(*) from test where age<
    (select age from test where id=10 )
      

  6.   

    select id,[排名]=(select count(1) from [user] where [user].[年龄]<=a.[年龄]) from [user] a where id=10