怎么排除上次已查询过的值
- SQL code
select top 16 * from tbl_picinfo a where a.[picid]>=( select max(b.[picid]) from ( select TOP 1 [picid] from tbl_picinfo where 1=1 ORDER BY [picid] )b) and a.[picid] in (select min(picid)[picid] from tbl_picinfo group by dcname,rcname) ORDER BY a.[picid]结果:12345791013[color=#FF0000]29313235414246[/color]select top 16 * from tbl_picinfo a where a.[picid]>=( select max(b.[picid]) from ( select TOP 17 [picid] from tbl_picinfo where 1=1 ORDER BY [picid] )b ) and a.[picid] in (select min(picid) [picid] from tbl_picinfo group by dcname,rcname) ORDER BY a.[picid] [color=#FF0000]29313235414246[/color]475556626472788187
请问该怎么去掉上次已查询过的呢,我是用做分页!不能太慢,或者有什么更高效的查询,望指点!
[解决办法]
做分页?
select *
from (
select id=row_number() over (order by getdate()),* from tb ) K
where id between 1 and 10
[解决办法]
楼上的想的太多了
[解决办法]
你的是sql 2000?
那就放到一个临时表中
select id=identity(int,1,1),* into #t from tb
然后
select * from #t where id between 1 and 10