DROP VIEW IF EXISTS PMBudgetTotalsByGroup
GO 
Create View PMBudgetTotalsByGroup
as
SELECT b.CompanyID, b.ProjectID, b.[Type], a.GroupID,a.GroupCD, sum(b.CuryAmount) as CuryAmount, 
sum(b.CuryRevisedAmount) as CuryRevisedAmount, 
sum(b.CuryCommittedAmount) as CuryCommittedAmount, 
sum(b.CuryCommittedInvoicedAmount) as CuryCommittedInvoicedAmount,
sum(b.CuryActualAmount) as CuryAtualAmount
from PMBudget b 
join PMAccountGroup a on b.CompanyID = a.CompanyID and b.AccountGroupID = a.GroupID 
group by b.CompanyID, b.ProjectID, b.[Type], a.GroupID,a.GroupCD