比如查找20-40行~~~~~~~~海量数据,要求性能比较高

解决方案 »

  1.   

    --例子
    declare @t table(id int,name varchar(10))
    insert into @t select 1,'aa'
    insert into @t select 2,'aa2'
    insert into @t select 3,'aay'
    insert into @t select 4,'aa3'
    insert into @t select 5,'aa4'
    insert into @t select 6,'aa3'
    insert into @t select 7,'a2a'
    insert into @t select 8,'aa2'
    insert into @t select 9,'aa4'
    insert into @t select 10,'a3a'
    insert into @t select 11,'afa'
    insert into @t select 12,'a2a'
    insert into @t select 13,'a2a'--取6-9行
    select * from (select top 4 * from (select top 9 * from @t order by id)a order by id desc)b order by id
      

  2.   

    --如果表中有類似ID的排序列,以下為得到21-40行。
    Select TOP 20 * From TableName Where ID Not In (Select TOP 20 ID From TableName Order By ID) Order By ID
      

  3.   

    我有自己的方法了&paoluo差不多简单写一下 select top 20 * from ( select top 40 * from *** order by id asc ) temp order by id desc
    效率应该更高一些...
      

  4.   

    暈,那分怎麼給我了,你的語句和xeqtr1982(HaN)的一樣啊。