select t2.tenterprise_userid,
       t3.fsaler,
       t3.fname,
       t3.fprovince,
       t3.fcity,
       t3.fcounty,
       t3.fphonenumber,
       MAX(t4.createdate) as                              flastreadtime,
       count(t4.tarchives_sc_useid)                       freadcount,
       sum(DATEDIFF(MINUTE, t4.createdate, t4.closedate)) freadtimes
from tarchives_sc t1
         inner join tenterprise_users t2 on t1.siteid = t2.siteid and t2.fphonenumber is not null
    and t1.fagentcanread = 1 and t2.fusertype = '¾­ÏúÉÌ' and t2.fisadministrator = 1
         inner join user_agent_saler_view t3 on t1.siteid = t3.siteid and t2.tenterprise_userid = t3.tenterprise_userid
         inner join tarchives_sc_userdata t4
                    on t1.siteid = t4.siteid and t2.tenterprise_userid = t4.tenterprise_userid and
                       t1.tarchives_scid = t4.tarchives_scid
where t1.siteid = $siteid$ and t1.tarchives_scid = $tarchives_scid$ and t3.fsaleruserid in $tenterprise_userid$
group by t2.tenterprise_userid, t3.fsaler, t3.fname, t3.fprovince, t3.fcity, t3.fcounty, t3.fphonenumber