select  t1.fname,t1.fphonenumber,count(t2.tcustomer_receptid)freceptcount,MAX(t2.fdate)flastdate,MAX(t2.fcustaction)fcustaction,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 t1.fgiveuptime is null and (t1.ffollowuptime is null or DATEADD(DAY,14,t1.ffollowuptime)<=GETDATE())
and isnull(t1.ffirstorderid,'') =''
group by t1.fname,t1.fphonenumber,t1.fcommunity,t1.fnumber
having DATEADD(DAY,14,MAX(t2.fdate))<=GETDATE() and DATEADD(MONTH,1,MAX(t2.fdate))>=GETDATE()
order by MAX(t2.fdate)