sql查询表N到M行的数据,查询表内最新标识列

sql查询表N到M行的数据,查询表内最新标识列

第一比较傻的方法

select * from (select top (m-n+1) * from (select topm * from 表) a order by a.Id desc) b order by b.Id第二有技术含量的方法

select * from (select *,ROW_NUMBER() over (order by id)px from 表)as t where px>n and px<=m

第三种换个思路

select top m-(n-1) * from 表 where id not in (select top n-1 id from 表 order by Id) order by Id

--查询n到m行的数据

你是哪个...

谁还有其他方法欢迎留言

加点内容

查询表内最新的标识列 有时候很有用select IDENT_CURRENT('表名')