写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增长的ID作为主键,注意:ID可能不是连续的。

解答一:(普通语句)

select top 10 * from A where id not in (select top 30 id from A)

解答二:(分页思想)

select * from (
select ID, ROW_NUMBER() OVER(ORDER BY ID asc) as row
from A ) AS T
where T.row>30 and T.row<=40

 

注:当然还有很多其他的解答,比如用ID大与第30行的,top10。。。

 

 

posted on 2013-03-11 13:03  Sean.Fan  阅读(265)  评论(0编辑  收藏  举报