select top 10 * from test order by aid desc也即按照aid排列的最后10位,但又希望展示的内容按照顺序排列,如果不用desc,又无法求出最后10位,请大家帮忙,谢谢

解决方案 »

  1.   

    declare @test table(aid int,[name] varchar(10))
    insert into @test select 1,'aa'
    insert into @test select 2,'a2a'
    insert into @test select 3,'a242a'
    insert into @test select 4,'a2a'
    insert into @test select 5,'a23a'
    insert into @test select 6,'a42a'
    insert into @test select 7,'aa'
    insert into @test select 8,'a434a'
    insert into @test select 9,'ara'
    insert into @test select 10,'a4a'
    insert into @test select 11,'area'
    insert into @test select 12,'aa'
    insert into @test select 13,'area'
    insert into @test select 14,'rer'
    insert into @test select 15,'t4r'select * from (select top 10 * from @test order by aid desc)a order by aid
      

  2.   

    select * from (select top 10 * from test order by aid desc) a order by 内容字段
      

  3.   

    declare @test table(aid int,[name] varchar(10))
    insert into @test select 1,'aa'
    insert into @test select 2,'a2a'
    insert into @test select 3,'a242a'
    insert into @test select 4,'a2a'
    insert into @test select 5,'a23a'
    insert into @test select 6,'a42a'
    insert into @test select 7,'aa'
    insert into @test select 8,'a434a'
    insert into @test select 9,'ara'
    insert into @test select 10,'a4a'
    insert into @test select 11,'area'
    insert into @test select 12,'aa'
    insert into @test select 13,'area'
    insert into @test select 14,'rer'
    insert into @test select 15,'t4r'select * from (select top 10 * from @test order by aid desc)a order by [name]
    --没看清。呵呵
      

  4.   

    select * from (select top 10 * from test order by aid desc) a order by aid
      

  5.   

    select * from test where aid in(select top 10 aid from test order by aid desc) order by aid asc
      

  6.   

    select  *  from ( 
    select top 10 * from
    test order by aiddesc )a
    order by aid