psqlexception error cannot take logarithm of zero code example
Example: division by zero postgres
-- 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