select k.计算日期,sum(k.销量)as 销量,sum(k.结算收入)as 结算收入,sum(k.收入贡献)as 收入贡献 from( select a.khm as 客户名称 ,case when a.dkjedw=1 then a.dkje*a.hl/10000 else a.dkje*hl end as 销量 ,a.jssr as 结算收入 ,a.srgx as 收入贡献 ,a.jsrq as 计算日期 ,b.khjl as 客户经理 ,b,xm as 客户名称显示 from uf_ddgl a left join uf_khgl b on b.id=a.khm left join dbo.[HrmResource] c on c.id = b.khjl where a.jsfs='1' and a.ddzt in('2','3') and jsrq>='${ksrq}' and jsrq<='${jsrq}' union all select a.khm as 客户名称 ,case when a.dkjedw=1 then a.dkje*a.hl/10000 else a.dkje*hl end as 销量 ,b.jssr as 结算收入 ,b.srgx as 收入贡献 ,b.jxrq as 计算日期 ,c.khjl as 客户经理 ,b.xm as 客户名称显示 from uf_ddgl a left join uf_ddgl_dt1 b on b.mainid=a.id left join uf_khgl c on c.id=a.khm left join dbo.[HrmResource] d on d.id = c.khjl where a.jsfs='0' and a.ddzt in('2','3') and jxrq>='${ksrq}' and jxrq<='${jsrq}' )k |