[thelist] Avoiding Divide by Zero within SQL...

Joshua Olson joshua at alphashop.net
Fri Nov 30 13:03:59 CST 2001


Sounds like you need the case...when statement.

Ala

SELECT
  myval =
   case
      when [denominator calculation] IN (0, NULL) then 0
      else [full calculation]
    end
FROM [table]

HTH,

-joshua

----- Original Message -----
From: "Anthony Baratta" <Anthony at Baratta.com>
Subject: [thelist] Avoiding Divide by Zero within SQL...


: (rudy is going to fall outta his chair laughing at this, but I swear it's
a
: different problem with Null. ;-)
:
: I'm trying to run some stats/percentages on some data in MS SQL.
: Unfortunately some of the data is "Null".





More information about the thelist mailing list