取A表中31-40行数据(id不连续)sqlserver的写法

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

sql server:两种写法。

解1:

select top 10 * from Students where Id not in(select top 30 id from Students order by id )

解2:

select top 10 * from Students where id>(select MAX(id) from (select top 30 id from Students order by Id) as Students)

 

posted @ 2017-06-23 01:18  狼牙者.net  阅读(570)  评论(0)    收藏  举报