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:
For every divisor that is zero, you will get a zero in the result set
- <code>
- SELECT ( 45 / NULLIF( 0, 0 ) ) AS value
- </code>