Divide by 0 issue

  • I am trying to divide in SQL:

    Total_Duty / ([Chap 99 Rate] + DutyRate) as Entererd_Value
    I think is have to cast as numeric, but nothing i've tries is working.

    Thoughts?

    As always, much appreciated.

  • I finally found that using NULLIF in the denominator works for me, 
    thanks

  • jeffshelix - Friday, December 7, 2018 11:53 AM

    I am trying to divide in SQL:

    Total_Duty / ([Chap 99 Rate] + DutyRate) as Entererd_Value
    I think is have to cast as numeric, but nothing i've tries is working.

    Thoughts?

    As always, much appreciated.

    The question is: what do you want to happen in the case where the divisor is zero?
    For example:

    • Return zero
    • Return NULL
    • Throw an error
    • Return some other value

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply