Formula issue in SQL when one result has 0 value

sql if zero then 1
divide by zero error encountered in sql server query
divide by zero error encountered in sql server stored procedure
nullif
coalesce sql
error: division by zero postgresql
isnull sql
sql divide by null