日期:2014-05-19  浏览次数:20403 次

这样的 select 语句怎么写?
我要搜索   从第10条记录开始的3条记录,   用   select   语句怎么写?
因为我已经   select   top   9   ID   from   mydatabase   了,现在要   从第10到12条记录。

------解决方案--------------------
if object_id( 'ta ')> 0 drop table ta

create table ta(A int identity(1,1),B varchar(8))

insert into ta
select 'A1 ' union all select 'A2 ' union all select 'A3 ' union all select 'A4 '
union all select 'A5 ' union all select 'A6 ' union all select 'A7 ' union all select 'A8 '
union all select 'A9 ' union all select 'A10 ' union all select 'A11 ' union all select 'A12 '
union all select 'A13 ' union all select 'A14 ' union all select 'A15 ' union all select 'A16 '

select top 3 * from ta a where a.A not in(select top 9 A from ta B order by B.A) order by a.A

--***结果
/*
A B
----------- --------
10 A10
11 A11
12 A12
*/

drop table ta