SELECT SUM(fnewreceptioncount) AS fnewreceptioncount,SUM(t.fnewordercount) AS fnewordercount,
       SUM(t.favgorderamount) AS favgorderamount,SUM(t.flkhrate) AS flkhrate,
       SUM(t.fjzgsrate) AS fjzgsrate,SUM(t.fhdrate) AS fhdrate,
       SUM(t.fyyrate) AS fyyrate,SUM(t.flsrate) AS flsrate
FROM
    (
        SELECT count(0) AS fnewreceptioncount,0 AS fnewordercount,0 AS favgorderamount,0 AS flkhrate,0 AS fjzgsrate,0 AS fhdrate,0 AS fyyrate,0 AS flsrate FROM tcustomer_reception t1
                                                                                                                                                                    inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
        WHERE t1.siteid = $siteid$ AND t2.fsaleruserid in $fsaleruserid$ AND convert(varchar(7), t1.createdate, 120) = $fdate$

        UNION all
SELECT 0 AS fnewreceptioncount,count(0) AS fnewordercount,convert(int,isnull(AVG(forderamount),0)) AS favgorderamount,
       convert(decimal(16,2),convert(float,count(case when fchannel='老客户' then 0 end))/convert(float,case when count(0)=0 then 1 else count(0)end)) AS flkhrate,
       convert(decimal(16,2),convert(float,count(case when fchannel='家装公司' then 0 end))/convert(float,case when count(0)=0 then 1 else count(0)end)) AS fjzgsrate,
       convert(decimal(16,2),convert(float,count(case when fchannel='活动' then 0 end))/convert(float,case when count(0)=0 then 1 else count(0)end)) AS fhdrate,
       convert(decimal(16,2),convert(float,count(case when fchannel='异业' then 0 end))/convert(float,case when count(0)=0 then 1 else count(0)end)) AS fyyrate,
       convert(decimal(16,2),convert(float,count(case when fchannel='零售' then 0 end))/convert(float,case when count(0)=0 then 1 else count(0)end)) AS flsrate
FROM tcustomer_reception t1
         inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
WHERE t1.siteid = $siteid$ AND t2.fsaleruserid in $fsaleruserid$ AND t1.ftype = '销售' AND convert(varchar(7), t1.createdate, 120) = $fdate$

    ) t