If you know you are going to have zeros appear in the denominator of formulas in a stored procedure or function, use the nullif function to null them out, e.g. nullif(, 0).