select t1.tagentactivitiesid,
       t1.tenterprise_userid,
       t1.ftitle,
       t1.checkby,
       t1.checkdate,
       t4.fcompshortname,
       t1.fstatus,
       count(t2.tagentactivities_shareid) fsharecount,--分享次数
       SUM(t3.fvisitors)                  freadcount,--浏览次数
       count(t3.tagentactivities_custid)  fcustcount--流量，阅读人数
from tagentactivities t1
         left join tagentactivities_share t2 on t1.siteid = t2.siteid and t1.tagentactivitiesid = t2.tagentactivitiesid
         left join tagentactivities_cust t3 on t1.siteid = t3.siteid and t1.tagentactivitiesid = t3.tagentactivitiesid
         left join tenterprise t4 on t1.siteid = t4.siteid
where t1.siteid =$siteid$ and t1.tagentsid=$tagentsid$
group by t1.tagentactivitiesid, t1.tenterprise_userid, t1.ftitle,
    t1.checkby, t1.checkdate, t4.fcompshortname, t1.fstatus