select t.* from tb t where (其他条件) and adtime = (select min(adtime) from tb where (其他条件) and adregid = t.adregig)select t.* from tb t where (其他条件) and adtime = (select max(adtime) from tb where (其他条件) and adregid = t.adregig)
select AdUserId,AdRegId ,AdRegIp,AdTime,LastLogonIP,users.Age from UserAccounts as users,Adinfo t where RegType='1' and users.userid=Adinfo.AdRegId and LastLogonIP!='' and Adtime between '2009-3-26 0:00:00' and '2009-3-27 0:00:00' and ADSiteID=1001 and not exists(select 1 from Adinfo where Adregid=t.Adregid and Adtime>t.Adtime)
dawugui 能在我原来那个代码上修改下吗? htl258 发的这个语法错误
ls的就不会把表数据和结构都用sql整出来? 还得让dawugui自己慢慢添加数据!
select * from def where adregid in (select min(adregid) from def group by adregip having count(adregid)>1 ) union select * from def where adregid in (select max(adregid) from def group by adregip having count(adregid)=1 )
from UserAccounts as users,Adinfo t
where RegType='1' and users.userid=Adinfo.AdRegId
and LastLogonIP!='' and Adtime between '2009-3-26 0:00:00' and '2009-3-27 0:00:00'
and ADSiteID=1001
and not exists(select 1 from Adinfo where Adregid=t.Adregid and Adtime>t.Adtime)
htl258 发的这个语法错误
还得让dawugui自己慢慢添加数据!
union
select * from def where adregid in (select max(adregid) from def group by adregip having count(adregid)=1 )