Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: zero divide by zero - 10g

    Hi

    I have a case where both the numerator and denominator are '0'. And this results in a 'blank'.

    Code:
    Can I make the result of 0/0=0 instead of null?
    I know if the numerator was non-zero and the den 0, then I can use decode.....etc but in my case the numerator is also zero.

    Regards
    Shajju

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    it will never be null, in oracle if you are dividing by zero you will always get the error

    ORA-01476: divisor is equal to zero
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Quote Originally Posted by shajju View Post
    Hi

    Can I make the result of 0/0=0 instead of null?
    With caution and probable erroneous results, you could use the NVL() function:
    Code:
    SQL> SELECT 0 / NVL (NULL, 1) FROM DUAL;
    
    0/NVL(NULL,1)
    -------------
                0
    
    SQL>
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •