select *
from (
         select t3.fname as                                    fsalername,
                t1.fagentnum,
                t1.fagentshortname,
                t1.fprovince,
                t1.fcity,
                t1.fcounty,
                DATEDIFF(day, convert(varchar(10), MAX(isnull(convert(varchar(10),t2.createdate,120), isnull(t1.fbegdate,'2000-01-01'))), 120),
                         convert(varchar(10), GETDATE(), 120)) fdays
         from tagents t1
                  left join tcustomer_reception t2 on t1.siteid = t2.siteid and t1.tagentsid = t2.tagentsid and t2.ftype='ÏúÊÛ'
                  left join tenterprise_users t3 on t1.siteid = t3.siteid and t1.fsaleruserid = t3.tenterprise_userid
              where t1.siteid=$siteid$ and t1.fsaleruserid in $fsaleruserid$
         group by t1.siteid, t1.fagentnum, t1.fagentshortname, t1.fsaleruserid, t1.fprovince, t1.fcity, t1.fcounty,
                  t3.fname
     ) t1
where t1.fdays >= 7