Check out example codes for "division by zero postgres". It will help you in understanding the concepts better.

Code Example 1

-- avoid division error in Postgres
value/NULLIF(col, 0)  -- if col == 0, NULL will be returned
value/COALESCE(NULLIF(col, 0), 1)  -- if col == 0, value will be returned

Learn ReactJs, React Native from akashmittal.com