select top 1 * from aa where selected='1' order by updtime desc
select top 1 * from aa where selected=1 order by updtime desc
你自己循环@第几页变量就可以取出了 declare @SQLStr varchar(8000) set @SQLStr='SELECT Top '+cast(1 as varchar)+' * FROM 表 WHERE 主键列 NOT IN (SELECT TOP '+cast(1*@第几页 as varchar)+' 主键列 from 表 )' exec(@SQLStr)
select top 1 * from aa where selected='1' order by updtime desc
选出符合条件的最大值和最小值 select * from aa where selected='1' and uptime between min(GetTime()-uptime) and max(GetTime()-uptime)
应该是这样 select * from aa where selected='1' and uptime between min(GetDate()-uptime) and max(GetDate()-uptime)
declare @SQLStr varchar(8000)
set @SQLStr='SELECT Top '+cast(1 as varchar)+' * FROM 表 WHERE 主键列 NOT IN (SELECT TOP '+cast(1*@第几页 as varchar)+' 主键列 from 表 )'
exec(@SQLStr)
select * from aa
where selected='1' and uptime between min(GetTime()-uptime) and max(GetTime()-uptime)
select * from aa
where selected='1' and uptime between min(GetDate()-uptime) and max(GetDate()-uptime)