日期:2014-05-17 浏览次数:20524 次
select bbd.Consignor as '委托方',cmf.InputDepartment as '部门'
,COUNT(case when CostType='0' and Flag_ClosingCost='0' then bbd.Consignor else 0 end)
,(sum(case when CostType='0' and Flag_ClosingCost='0' then ShouldMoney else 0 end)*Currency_Rate) as '应收金额'
,(sum(case when CostType='1' and Flag_ClosingCost='0' then ShouldMoney else 0 end)*Currency_Rate) as '应付金额'
,(sum(case when CostType='0' and Flag_ClosingCost='0' then ShouldMoney else 0 end)*Currency_Rate)-
(sum(case when CostType='1' and Flag_ClosingCost='0' then ShouldMoney else 0 end)*Currency_Rate) as '毛利润'
,[Money] as '管理费用'
,(((sum(case when CostType='0' and Flag_ClosingCost='0' then ShouldMoney else 0 end)*Currency_Rate)-
(sum(case when CostType='1' and Flag_ClosingCost='0' then ShouldMoney else 0 end)*Currency_Rate))-([Money])) as '纯利润'
from [cost_FeeInfo] as cfi,bus_BusinessDetail as bbd,cost_ManageFee as cmf
where cfi.BusinessNum=bbd.BusinessNum and cmf.Consignor = bbd.Consignor
GROUP BY bbd.Consignor,cmf.InputDepartment,[Money],Currency_Rate
select bbd.Consignor as '委托方',cmf.InputDepartment as '部门'
,COUNT(case when CostType='0' and Flag_ClosingCost='0' then bbd.Consignor else 0 end)
,(sum(case when CostType='0' then ShouldMoney else 0 end)*Currency_Rate) as '应收金额'
,(sum(case when CostType='1' then ShouldMoney else 0 end)*Currency_Rate) as '应付金额'
,(sum(case when CostType='0' then ShouldMoney else 0 end)*Currency_Rate)-
(sum(case when CostType='1' then ShouldMoney else 0 end)*Currency_Rate) as '毛利润'
,[Money] as '管理费用'
,(((sum(case when CostType='0' then ShouldMoney else 0 end)*Currency_Rate)-
(sum(case when CostType='1' then ShouldMoney else 0 end)*Currency_Rate))-([Money])) as '纯利润'
from [cost_FeeInfo] as cfi,bus_BusinessDetail as bbd,cost_ManageFee as cmf
where cfi.BusinessNum=bbd.BusinessNum and cmf.Consignor = bbd.Consignor
GROUP BY bbd.Consignor,cmf.InputDepartment,[Money],Currency_Rate