I've written the following query to find the charge by procedure for the current month, previous month, and fiscal year. The query works find until I try to join a new table (Rendering AS r ON r.[Rendering ID] = c.[Rendering Id]) so that I can pull in the name of the Rendering Provider. When I join the table either in another nested select or through an INNER JOIN, my sum results are quadrupled! What am I doing wrong? I've tried everything I know how to do except for a UNION, which won't work because in want a new column and not new rows of data?? Any and all advice will be greatly appreciated. (Sorry for the messy code - pulled query right out of Access).
====
SELECT cc.[Item Name], (SELECT IIF(ISNULL(Sum(c2.[Billed Charge])), 0, CCur(Sum(c2.[Billed Charge]))) FROM Charges AS c2 WHERE c2.[CPT Code] = c.[CPT Code] AND Month(c2.[Claim Date]) = (Month(Tempvars!ReportDate) - 1) AND c2.[Claim Date] > Tempvars!FiscalYearStart-1) AS [Curr Mth Ins Charge], (SELECT IIF(ISNULL(Sum(c3.[Billed Charge])), 0, CCur(Sum(c3.[Billed Charge]))) FROM Charges AS c3 WHERE c3.[CPT Code] = c.[CPT Code] AND Month(c3.[Claim Date]) = (Month(Tempvars!ReportDate) - 2) AND c3.[Claim Date] > Tempvars!FiscalYearStart-1) AS [Prev Mth Ins Charge], IIf(IsNull(Sum(c.[Billed Charge])),0,CCur(Sum(c.[Billed Charge]))) AS [FY Ins Charge] INTO [CPT Summary]
FROM Charges AS c INNER JOIN CPT_Codes AS cc ON c.[CPT Code] = cc.[CPT Code]
WHERE (((1)=1) AND ((c.[Claim Date]) Between [Tempvars]![FiscalYearStart] And [Tempvars]![FiscalYearEnd]))
GROUP BY cc.[Item Name], c.[CPT Code];
====
SELECT cc.[Item Name], (SELECT IIF(ISNULL(Sum(c2.[Billed Charge])), 0, CCur(Sum(c2.[Billed Charge]))) FROM Charges AS c2 WHERE c2.[CPT Code] = c.[CPT Code] AND Month(c2.[Claim Date]) = (Month(Tempvars!ReportDate) - 1) AND c2.[Claim Date] > Tempvars!FiscalYearStart-1) AS [Curr Mth Ins Charge], (SELECT IIF(ISNULL(Sum(c3.[Billed Charge])), 0, CCur(Sum(c3.[Billed Charge]))) FROM Charges AS c3 WHERE c3.[CPT Code] = c.[CPT Code] AND Month(c3.[Claim Date]) = (Month(Tempvars!ReportDate) - 2) AND c3.[Claim Date] > Tempvars!FiscalYearStart-1) AS [Prev Mth Ins Charge], IIf(IsNull(Sum(c.[Billed Charge])),0,CCur(Sum(c.[Billed Charge]))) AS [FY Ins Charge] INTO [CPT Summary]
FROM Charges AS c INNER JOIN CPT_Codes AS cc ON c.[CPT Code] = cc.[CPT Code]
WHERE (((1)=1) AND ((c.[Claim Date]) Between [Tempvars]![FiscalYearStart] And [Tempvars]![FiscalYearEnd]))
GROUP BY cc.[Item Name], c.[CPT Code];