有一个表有100条记录,显示20-30之间的记录,怎么写SQL语句。

解决方案 »

  1.   

    select top 10 * 
    from (select top 30 * from tbl order by 主键 desc)
    order by 主键 asc
      

  2.   

    select top 10 * from 表名 where id not in (select top 10 id from 表名)
      

  3.   

    有一个又笨又实用的方法.呵呵这个用的是pubs表select identity(int,1,1)as a_id,* into authors_copy from authors select * from authors_copy where a_id between 20 and 30要复杂的话,就得用游标了~
      

  4.   

    select top 10 * 
    from (select top 30 * from tbl order by 主键 asc)
    order by 主键 desc
      

  5.   

    select identity(int,1,1)as a_id,* into authors_copy from authors select * from authors_copy where a_id between 20 and 30
    好,用另一种要排序,破坏了顺序
      

  6.   

    select top 10 * 
    from (select top 30 * from tbl order by 主键 asc)
    order by 主键 desc这样子直接吧select identity(int,1,1)as a_id,* into authors_copy from authors select * from authors_copy where a_id between 20 and 30
    不知道哪个效率高  ?
      

  7.   

    select top 10* 
    from (select top 20* from tbl order by 主键asc) x 
    order by 主键desc
      

  8.   

    zhanbairu(sa) ( ) 信誉:100  2006-07-26 10:49:00  得分: 0   select top 10 * from 表名 where id not in (select top 10 id from 表名)--------
    我测了下,不行,下面这个可以。但却想不明白,盼各位指点下,谢谢!!select top 11 * from 表名 where id not in (select top 19 id from 表名 
    order by id asc) order by id asc
      
     
      

  9.   

    select ID=identity(int, 1, 1), * into # from 表名
    select * from # where ID between 20 and 30
      

  10.   

    select * from table where id between 10 and 30????