SELECT Departments.deName, GLSub.gsAccount AS Account, Total.itAmount AS Total, JanMrt.itAmount AS JanMrt, AprJun.itAmount AS AprJun, JulSep.itAmount AS JulSep, JanMrt.itAmount + AprJun.itAmount + JulSep.itAmount AS Test FROM PayEmps JOIN Departments ON Departments.DeKey = PayEmps.paDeKey JOIN Runs ON Runs.ruKey = PayEmps.paRuKey LEFT JOIN (SELECT IT.itGsKey, PE.paDeKey, SUM(IT.itAmount) AS itAmount FROM dbo.HistItems IT JOIN Runs RU ON It.itRuKey = RU.ruKey JOIN PayEmps PE ON IT.itEmKey = PE.paEmKey AND IT.itRuKey = PE.paRuKey JOIN GlSub ON GlSub.gsKey = IT.itGsKey WHERE RU.ruYear = 2015 AND GLSub.gsAccount = '4101' GROUP BY IT.itGsKey, PE.paDeKey) as Total ON PayEmps.paDeKey = Total.paDeKey LEFT JOIN (SELECT IT.itGsKey, PE.paDeKey, SUM(IT.itAmount) AS itAmount FROM dbo.HistItems IT JOIN Runs RU ON It.itRuKey = RU.ruKey JOIN PayEmps PE ON IT.itEmKey = PE.paEmKey AND IT.itRuKey = PE.paRuKey JOIN GlSub ON GlSub.gsKey = IT.itGsKey WHERE RU.ruYear = 2015 AND MONTH(RU.ruStartDat) IN (1,2,3) AND GLSub.gsAccount = '4101' GROUP BY IT.itGsKey, PE.paDeKey) as JanMrt ON PayEmps.paDeKey = JanMrt.paDeKey LEFT JOIN (SELECT IT.itGsKey, PE.paDeKey, SUM(IT.itAmount) AS itAmount FROM dbo.HistItems IT JOIN Runs RU ON It.itRuKey = RU.ruKey JOIN PayEmps PE ON IT.itEmKey = PE.paEmKey AND IT.itRuKey = PE.paRuKey JOIN GlSub ON GlSub.gsKey = IT.itGsKey WHERE RU.ruYear = 2015 AND MONTH(RU.ruStartDat) IN (4,5,6) AND GLSub.gsAccount = '4101' GROUP BY IT.itGsKey, PE.paDeKey) as AprJun ON PayEmps.paDeKey = AprJun.paDeKey LEFT JOIN (SELECT IT.itGsKey, PE.paDeKey, SUM(IT.itAmount) AS itAmount FROM dbo.HistItems IT JOIN Runs RU ON It.itRuKey = RU.ruKey JOIN PayEmps PE ON IT.itEmKey = PE.paEmKey AND IT.itRuKey = PE.paRuKey JOIN GlSub ON GlSub.gsKey = IT.itGsKey WHERE RU.ruYear = 2015 AND MONTH(RU.ruStartDat) IN (7,8,9) AND GLSub.gsAccount = '4101' GROUP BY IT.itGsKey, PE.paDeKey) as JulSep ON PayEmps.paDeKey = JulSep.paDeKey LEFT JOIN GLSub ON Total.itGsKey = GLSub.gsKey AND JanMrt.itGsKey = GLSub.gsKey AND AprJun.itGsKey = GLSub.gsKey AND JulSep.itGsKey = GLSub.gsKey WHERE Runs.ruYear = 2015 AND GLSub.gsAccount = '4101' GROUP BY Departments.deName, GLSub.gsAccount, Total.itAmount, JanMrt.itAmount, AprJun.itAmount, JulSep.itAmount ORDER BY Departments.deName, GLSub.gsAccount