I need help putting together a query to calculate Unit Cost. Unit Cost formula is (Volume of completed work divided by DNIE (Direct Non-Interest Expense ))
Volume of complete work is in two tables and DNIE is in one table
In addition to overall Unit Cost, I need to calculate Unit Cost by AU (Accounting Unit )
Below I have the formulas to get Unit Cost, one query to get DNIE, and one query to get volume of completed work. I dont know how to put these all together. Any help would be appreciated
---- UnitCost calculation------------- Overall_UnitCost (sum of all services volume / sum of all DNIE) Midrange Unit Cost = Midrange volume / (50% AU 74667+ 33% of AU DNIE 207497) Mainframe Unit Cost = Mainframe Volume / (50% AU 74667+ 33% of AU DNIE 207497) ------------------------------------------- ----- DNIE , UNIT COST -------------------- ---------------------------------- Select Team ,Service , DNIE , AU --, ? as Overall_UnitCost (sum of all services / sum of all DNIE) --, ? as OP_UnitCost (Open Systems - Build and Deploy volume + Open Systems Anthill volume / (AU DNIE 46573 + 33% of AU DNIE 207497)) --, ? as MR_UnitCost (Midrange volume / (50% AU 74667 + 33% of AU DNIE 207497)) --, ? as MF_UnitCost (Unit Cost = Mainframe Volume / (50% AU 74667 + 33% of AU DNIE 207497)) ,YEAR(Date)asYear ,MONTH(Date)asMonth ,SUBSTRING(DATENAME(month,Date),1,3)+' '+ LTRIM((STR(year(Date)))) as MonthYear From aid1405.dbo.UnitCost2 whereserviceNOT LIKE'PRODUCT MGMT' GROUPBYSUBSTRING(DATENAME(month,Date),1,3)+' '+ LTRIM((STR(year(Date)))),YEAR(Date),MONTH(Date), AU, Team,Service, DNIE OrderbyYear desc,Monthdesc, MonthYear ---------------------------------------- ----- VOLUME -------------------- ---------------------------------- Select Team,Service, sum(A.Cnt)as Cnt, A.Year, A.Month, A.MonthYearfrom ( -------- volume count from VolumeReportData SELECT Team,Service, COUNT(ID)as Cnt ,SUBSTRING(DATENAME(month,Actual_Install_End),1,3)+' '+ LTRIM((STR(year(Actual_Install_End)))) as MonthYear ,YEAR(Actual_Install_End)asYear ,MONTH(Actual_Install_End)asMonth FROM aid1405.dbo.VolumeReportData Where Team='CAMS' AND Actual_Install_End>DATEADD(m,-13,DateAdd("d",1-DatePart("d",getdate()),getdate())) ANDCONVERT(VARCHAR(10),CONVERT(VARCHAR(10),convert(datetime,Actual_Install_End,1),126),126)<CONVERT(VARCHAR(10),DateAdd("d",1-DatePart("d",getdate()),getdate()),126) AND Actual_Install_Endisnot null GROUPBYSUBSTRING(DATENAME(month,Actual_Install_End),1,3)+' '+ LTRIM((STR(year(Actual_Install_End)))),YEAR(Actual_Install_End),MONTH(Actual_Install_End), Team,Service -------- volume count from CamsVSummary UNIONALL select Team,Service, requests as Cnt ,SUBSTRING(DATENAME(month,DateSubmitted),1,3)+' '+ LTRIM((STR(year(DateSubmitted)))) as MonthYear ,YEAR(DateSubmitted)asYear ,MONTH(DateSubmitted)asMonth from aid1405.dbo.CamsVSummary Where Team='CAMS' AND DateSubmitted>=DATEADD(m,-13,DateAdd("d",1-DatePart("d",getdate()),getdate())) ANDCONVERT(VARCHAR(10),CONVERT(VARCHAR(10),convert(datetime,DateSubmitted,1),126),126)<CONVERT(VARCHAR(10),DateAdd("d",1-DatePart("d",getdate()),getdate()),126) GROUPBYSUBSTRING(DATENAME(month,DateSubmitted),1,3)+' '+ LTRIM((STR(year(DateSubmitted)))),YEAR(DateSubmitted),MONTH(DateSubmitted), requests, Team,Service ) AGroupby A.Year, A.Month, A.MonthYear, Team,Service Orderby A.Yeardesc, A.Monthdesc, A.MonthYear |