If the objective is to add all the relevant countAudit values together, add all the relevant error values together, then add those two sums together, and then divide that sum by 1,000,000, then what you have looks correct to me. If in doubt, you could always make a small data set for which you can manually determine what the result should be, then see if that's what your query returns. 🙂