select  max(t2.fdate)flastdate,t1.fname,t1.fphonenumber,convert(varchar(10),t1.fbirthdate,120)fbirthdate,t1.fwechatno,t1.fcommunity,t1.fnumber
from tcustomer t1
       inner join tcustomer_reception t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid and t1.tcustomerid=t2.tcustomerid and t2.ftype='ÏúÊÛ'
where t1.siteid=$siteid$ and t1.tagentsid=$tagentsid$ and convert(varchar(10),t1.fbirthdate,120)=convert(varchar(10),GETDATE(),120)
and  (freturnvisittime is null or YEAR(freturnvisittime)!=year(GETDATE()))
group by t1.fname,t1.fphonenumber,t1.fcommunity,t1.fnumber,t1.fbirthdate,t1.fwechatno
order by MAX(t2.fdate)