Using NULLIF() To Prevent Divide-By-Zero Errors In SQL
In case you want to return zero, in case a zero devision would happen, you can use:
SELECT ( 45 / NULLIF( 0, 0 ) ) AS value
For every divisor that is zero, you will get a zero in the result set
Comments
Post a Comment