select * from
(select *,ROW_NUMBER() over(order by id) as Row_Num from table) t
where t.Row_Num>=20 and t.Row_Num<30 作者: 无__畏 时间: 2013-6-9 11:47
select top 10 * from T_Books where id not in
(select top 19 id from T_Books t)作者: 王洪磊 时间: 2013-6-9 12:07
有三种方法可以实现:
一、搜索前20条记录,指定不包括前10条
语句:
select top 20 * from tbl where id not in (select top 10 id from tbl)
二、搜索记录生成临时表,建立临时表的自增id。通过取得自增id的10<id<20的记录的方法取得所需数据
语句:
select identity(int,1,1) as id,* into #temp from tbl;
select * from #temp where id between 10 and 20
第二个方法实际上是两条语句,但你可以让他连续执行,就像一条语句一样完成任务。
三、第三种方法:
语句:
SELECT TOP 10 * FROM (SELECT TOP 20 * FROM tblORDER BY id) as tbl2 ORDER BY tbl2.id DESC 作者: popoluno 时间: 2013-6-9 15:39
select top 10 * from T_Table where id not in(select top 19 id from T_Table)