group by AdRegIp  having count(AdRegIp)=1

解决方案 »

  1.   

    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)
      

  2.   

    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)
      

  3.   

    dawugui 能在我原来那个代码上修改下吗?
    htl258 发的这个语法错误
      

  4.   

    ls的就不会把表数据和结构都用sql整出来?
    还得让dawugui自己慢慢添加数据!
      

  5.   

    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 )