高手:
    我现在遇到这样一个问题: 我从数据库里面取10条记录,按时间排序,但现在客户有个要求----只显示最新10条记录中的“后9条”,把“最最新”的那一条留下来不要显示。
    于是我要对我现在的的SQL语句做个更改,我现在SQL语句如下
     Select Top 10 From DataTable Order By ID Time Desc 
   请高手帮我取最新的10条记录的后9条。
致谢!

解决方案 »

  1.   


    select top 9 * from (Select Top 10 * From DataTable Order By ID Time Desc) t order by Time
      

  2.   

    select * from (
    select row_number()over(order by dt desc) as id,dt from tb
    ) as a where id between 2 and 10
      

  3.   

    select top 9 * from (Select Top 10 * From DataTable Order By ID Time Desc) t order by Time
      

  4.   


    select * from (select top 9 * from (Select Top 10 * From tb Order By dt Desc) t order by dt) t order by dt desc
      

  5.   

    create table #EE
    (
     id int,
     [Name] varchar(10)
    )
    insert into #EE select 1,'aa'
    union all select 2,'bb'
    union all select 3,'cc'
    union all select 4,'dd'
    union all select 5,'bffb'
    union all select 6,'rr'
    union all select 8,'tt'
    union all select 10,'yy'
    union all select 13,'uu'
    union all select 15,'ii'
    union all select 16,'oo'
    union all select 21,'pp'select top 9 * from (select top 10 * from #EE order by id desc)cc order by id asc
      

  6.   

    t 就是as t 就是别名.