SQL
I need to perform the following query ORACLE
:
select
(DISPONIBILIDADES/EFECTIVO) as DISPONIBLE
from sbv
where banco = 'ACTIVO (BU)'
But I get the following error:
ORA-01476: divisor is equal to zero 01476. 00000 - "divisor is equal to zero"
The field EFECTIVO
has a value of 0. I know that a division by 0 gives an indeterminacy but I need that if the division is by 0, it gives me 0 as a result.
For this we can use a case to check that the value is not 0 before doing the division.
It is generally better accepted that the result of this division is
NULL
and not zero, since its meaning is precisely indeterminate .To achieve this, you can use the function
nullif
:If you want it to return zero anyway, you can use
nvl()
o `coalesce():