23
In MySQL, this query might throw a division by zero error:
SELECT ROUND(noOfBoys / noOfGirls) AS ration
FROM student;
If noOfGirls is 0 then the calculation fails.
What is the best way to handle this?
I would like to conditionally change the value of noOfGirls to 1 when it is equal to 0.
Is there a better way?