select * from (
select *, ROW_NUMBER() RN
from A
) where RN between 10 and 20
select top 10 * from A where id not in (select top 9 id from A)
上两个都正
ROW_NUMBER() as x只适于mssql 2005+
第二个也只适用于微软系的数据库
ALTER  PROCEDURE Company_ListPagedCustom
            @StartIndex int ,
            @EndIndex int ,
            @WHERE varchar(255),
            @ORDERBY varchar(255)
            AS 
            Declare @Sql varchar(1000)
            declare @Count int
            declare @orderbyopp varchar(100)
            select @count= count(*) from Company 
            if (@count<@EndIndex)
            begin
            set    @EndIndex=@count
            end
            if (CHARINDEX(LOWER(@ORDERBY),'desc')>0 )
            begin
            set    @orderbyopp =  REPLACE(LOWER(@ORDERBY),'desc','asc')
            end
            else
            begin
            set    @orderbyopp =  REPLACE(LOWER(@ORDERBY),'asc','desc')
            end
            if (@StartIndex >@EndIndex)
            begin
            set @StartIndex=0
            set @EndIndex=0
            end
            set @Sql='  SELECT *
            FROM  ( SELECT Top '+ CONVERT(varchar, (@EndIndex -@StartIndex+1))+' *  
            FROM  (SELECT Top '+CONVERT(varchar, @EndIndex)+'  * FROM Company where '+ @WHERE +' Order by '+@ORDERBY+' ) t1 Order by '+@ORDERBY+' ) t2
            Order by '+@ORDERBY+' '
            execute(@Sql)
来晚了。可以结案了