select top 40 column from table where column not in (select top 20 column from table )
用临时表吧 insert into #temp select identity(1,1),* from 结果集
select top 8 * from view_product_price where prodid not in(select top 16 prodid from product_price where pc4_id=256 or pc4_id=257 order by p_time desc) and pc4_id=256 or pc4_id=257 order by p_time desc
如果是sql 2005可以用row_number()函数如果没有能确定唯一值的列,那么2楼的方法就不能用了 如果有能确定唯一值的列select top 20 column from 结果集 where column not in (select top 19 column from 结果集)
如果没有确定唯一值的列.就用临时表吧.看3楼代码 给它添一个唯一列 identity(1,1)
select * from ( SELECT *, Row_Number() over (partition by Filed1 order by insert_time)as RowNumber FROM [Table]) T where RowNumber between 10 and 20
select top 20 column from table where column not in (select top 20 column from table)
用临时表,把所有结果都放在临时表里,并且把临时表里的每一条结果自动编个号 如: select identity(int,1,1) as id,* into #temp from 表 where 条件 现在,临时表里的每一条记录都有一个编号,从1开始的编号 所以,你分页的时候可以这样子取(假如你每页显示10条记录) select * from #temp where id>0 and id<=10 诸如此类的
where column not in (select top 20 column from table
)
insert into #temp
select identity(1,1),* from 结果集
如果是sql 2005可以用row_number()函数如果没有能确定唯一值的列,那么2楼的方法就不能用了
如果有能确定唯一值的列select top 20 column from 结果集
where column not in (select top 19 column from 结果集)
给它添一个唯一列 identity(1,1)
SELECT *,
Row_Number() over (partition by Filed1 order by insert_time)as RowNumber
FROM [Table]) T where RowNumber between 10 and 20
如:
select identity(int,1,1) as id,* into #temp from 表 where 条件
现在,临时表里的每一条记录都有一个编号,从1开始的编号
所以,你分页的时候可以这样子取(假如你每页显示10条记录)
select * from #temp where id>0 and id<=10
诸如此类的