Ignoring Divide by Zero

  • Comments posted to this topic are about the item Ignoring Divide by Zero

  • This has proven to be very handy

    Nice question, thanks Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • got it wrong but learnt something new,

    cheers Steve

    ---------------------------------------------------------------------------------------
    The more you know, the more you know that you dont know

  • I guess the real key here is that if you're dividing by zero, there's something wrong with your data, your code, or both.  I've never ignored divide by zero errors and probably never will. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • One approach to avoid dividing by 0 is the NULLIF trick:

    SELECT Numerator/NULLIF(Divisor, 0)

Viewing 5 posts - 1 through 4 (of 4 total)

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