使用sql查询表中第m行至n行的数据

来源:互联网 发布:qwq是什么网络意思 编辑:程序博客网 时间:2024/05/16 12:19

对于sqlserver2000,使用如下语句实现:

select * from

(
select *, couts=(select count(*)+1 from table where  id<t1.id) from table t1

) t2

where  couts between m and n

 

对于sqlserver2005,使用如下语句实现:

select * from

(

select  *,couts=row_number()+1 over(order by id) from table

) t

where couts between m and n

 





原创粉丝点击