#2
mywisdom882016-09-26 17:19
|
select a.月份,namezyry,作业数量,正式数量,预评数量,isnull(收费金额,0) 收费金额 , isnull(收费笔数,0) 收费笔数 from
(select namezyry,
count(0) 作业数量,
sum(case when zytype='正式' then 1 else 0 end) as 正式数量,
sum(case when zytype='预评' then 1 else 0 end) as 预评数量,
month(add_date) 月份
from [Fxpgoa15_Data].[dbo].[fxpg_business]
where 1 = 1
and
datediff(Month,add_date,getdate())=0
group by month(add_date),namezyry
) a
left join
(
select
SUM(moneysf) 收费金额,count(moneysf) 收费笔数,
month(Timesf) 月份
from [Fxpgoa15_Data].[dbo].[fxpg_business]
where
datediff(Month,Timesf,getdate())=0
group by month(Timesf)
) b
on a.月份 = b.月份
[local]1[/local]
收费金额 收费笔数 现在是9月总数,想改成和前面 公积金、招商银行、中信银行对应的数量和金额 。