select sum(t.factivitiescount) as factivitiescount,
       sum(t.famount)          as famount,
       sum(t.fcustcount)       as fcustcount,
       sum(t.fformcount)       as fformcount,
       sum(t.fsaler1count)     as fsaler1count,
       sum(t.fsaler2count)     as fsaler2count
from (
         select count(0)            as factivitiescount,--推广次数
                SUM(t1.fusedamount) as famount,--消费金额
                0                   as fcustcount,--流量，阅读人数
                0                   as fformcount,--线索，意向客户数
                0                   as fsaler1count,--一级推广人数
                0                   as fsaler2count--二级推广人数
         from tagentactivities t1
         where t1.siteid = $siteid$
           and t1.tenterprise_userid = $tenterprise_userid$
         union all
select 0                 as factivitiescount,
       0                 as famount,
       sum(t1.fvisitors) as fcustcount,
       0                 as fformcount,
       0                 as fsaler1count,
       0                 as fsaler2count
from tagentactivities_cust t1
         inner join tagentactivities t2 on t1.siteid = t2.siteid and t1.tagentactivitiesid = t2.tagentactivitiesid
where t1.siteid = $siteid$
  and t2.tenterprise_userid = $tenterprise_userid$
union all
select 0        as factivitiescount,
       0        as famount,
       0        as fcustcount,
       count(0) as fformcount,
       0        as fsaler1count,
       0        as fsaler2count
from tagentactivities_form t1
         inner join tagentactivities t2 on t1.siteid = t2.siteid and t1.tagentactivitiesid = t2.tagentactivitiesid
where t1.siteid = $siteid$
  and t2.tenterprise_userid = $tenterprise_userid$
union all
select 0        as factivitiescount,
       0        as famount,
       0        as fcustcount,
       0        as fformcount,
       count(0) as fsaler1count,
       0        as fsaler2count
from tenterprise_users
where siteid = $siteid$
  and tagentsid=$tagentsid$
union all
select 0        as factivitiescount,
       0        as famount,
       0        as fcustcount,
       0        as fformcount,
       0        as fsaler1count,
       count(0) as fsaler2count
from tpromoters
where siteid = $siteid$
  and tagentsid=$tagentsid$
  and fsaler1id=$tenterprise_userid$
  and fstatus=1
    ) t