Oscar Ng
0
Q:

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 
0

New to Communities?

Join the community