--创建临时表
create table tbDemo
(
iID int identity(1,1) not null
,iValue int
);
go
--插入测试数据
declare @flag int
set @flag=20
while @flag>=1
begin
insert into tbDemo(iValue) values(abs(CHECKSUM(NEWID())%1000))
set @flag=@flag-1
end;
go
--按照iValue升序,查询第11到15条记录
with Demo as
(
select *,ROW_NUMBER() over (order by iValue) as iOrder
from tbDemo
)
--select * from Demo
select *
from Demo
where iOrder>=11
and iOrder<=15
--删除测试表
drop table tbDemo
1万+

被折叠的 条评论
为什么被折叠?



