I have the following code and need help with the following:
1. This is supposed to pull records from the previous month and from the month before that. For example, from April and March. Instead of specifying month 4 and 3, I need to make sure that it is calling out the previous month and the month before that. Can someone help modify my code here to do that?
2. Where I have the function (SUM(MDM_Error), I need to incude the following (NPI_Counts) from the same table and have the (SUM(MDM_Error)) divided by the (NPI_Counts), can someone help with that as well?
SELECT PMG_BG, [PMG_BG_Level0]
,  AS Month3
,  AS Month4
,[PMG_BG_Level3],(R100_Error_E + R100_Error_W + R100_Error_A + R101_Error_E + R101_Error_W + R101_Error_A + R102_Error_E + R102_Error_W + R102_Error_A + R300_Error_E + R300_Error_W + R300_Error_A + R301_Error_E + R301_Error_W + R301_Error_A + R302_Error_E + R302_Error_W + R302_Error_A + R400_Error_E + R400_Error_W + R400_Error_A + R401_Error_E + R401_Error_W + R401_Error_A + R302_Error_E + R402_Error_W + R402_Error_A) AS MDM_Error, Month
WHERE (Month = MONTH(GETDATE()) - 1) OR (Month = MONTH(GETDATE()) - 2)
PIVOT (SUM(MDM_Error) FOR Month IN (,)) pvt