I took about 2 months off on this problem, and now I'm back to try and find a solution for a work around for "divide by zero" errors. I have the following that I'm working on (same as before mostly)...
SUM( Janunits + Febunits + Marunits + Aprunits + Mayunits + Jununits + Julunits + Augunits + Sepunits + Octunits + Novunits + Decunits ) AS CurrentTotal
It is possible that some of the records might have ZERO across all of the above fields.
Then I need to subtract the difference of the CurrentTotal from the PreviousTotal (previous total from the year before).
CurrentTotal - PreviousTotal = Difference
Once I have the difference amount, I then need to take that amount and divide it by the CurrentTotal and then multiply that result by 100
(Difference / CurrentTotal)*100 = PercentageDifference
Ok, so in the example above, there are a few of the rows that appear not to have had any activity over the past year. Resulting in a fatal Divide By Zero error message. Due to accounting restrictions, I can not filter out these rows, they must remain in the result set. I'm hoping for a solution to bypass the fatal error.
Any suggestions?