select sum(total) as sum, month
from
(
	select A.DOCNO as 项目号,a.TotalMoneyTC as total,a.CreatedOn as 创建日期,a3.PersonName_DisplayName as 业务员,
	a7.Name as 项目类型,A6.Name as 客户名称,A9.name AS 所属组织,Month(a.CreatedOn) as month
	from SM_SO as A
	left join CBO_Operators as A2 on(A.Seller = A2.ID)
	left join Base_Contact as A3 on (a2.Contact=a3.ID)
	left join SM_SODocType as A4 on (A.DocumentType = a4.ID)
	left join SM_SODocType_Trl as A7 ON (A4.ID=A7.ID)
	left join CBO_Customer as A5 on(A.OrderBy_Customer = A5.ID)
	left join CBO_Customer_Trl as A6 on (A5.ID=A6.ID) AND (A6.SysMLFlag = 'zh-CN')
	left join Base_Organization as A8 on (A.Org = A8.ID)
	left join Base_Organization_Trl as a9 on (a8.ID = a9.ID)
	where A5.CODE not in ('S-00002','S-00003')  --过滤内部交易的订单
) a
group by month
order by month asc
