select t3.fsaleruserid,
       t4.fname,
       count(distinct t2.tenterprise_userid)                              as frequireqty,
       count(distinct case when t2.fstatus = 'Μα½»' then t2.tenterprise_userid  else null end) as fsubmitqty,
       t1.fnotes,
       t1.fbegdate,
       t1.fenddate,
       t1.ftitle,
       t1.fisnotlimittimes
from DSBCRM..tsubmiteditmodel t1
       inner join DSBCRM..tsubmitedit t2 on t1.siteid = t2.siteid and t1.tsubmiteditmodelid = t2.tsubmiteditmodelid
       inner join DSBCRM..tagents t3 on t2.siteid = t3.siteid and t2.tagentsid = t3.tagentsid
       inner join DSBCRM..tenterprise_users t4 on t3.siteid = t4.siteid and t3.fsaleruserid = t4.tenterprise_userid
where t1.siteid =$siteid$ and t1.tsubmiteditmodelid=$tsubmiteditmodelid$ and t3.fsaleruserid in $fsaleruserid$
group by t3.fsaleruserid, t4.fname,t1.fnotes,t1.fbegdate,t1.fenddate,t1.ftitle,t1.fisnotlimittimes