ISNULL varient that will display one value if null and one value if not

ISNULL varient that will display one value if null and one value if not

Post by Ric » Sat, 27 Sep 2003 23:02:43



I am looking for a varient of isnull function that will allow me to
display 0 if the column is null and 1 if it is not.

Is there a function that will display 0 if the column is null and 1 if
it is not?

 
 
 

ISNULL varient that will display one value if null and one value if not

Post by Vern Rab » Sat, 27 Sep 2003 23:25:00


That would be CASE, e.g.,

select case
   when colname is null then 0
   else 1
   end
from ...

HTH
Vern

Quote:>-----Original Message-----
>I am looking for a varient of isnull function that will
allow me to
>display 0 if the column is null and 1 if it is not.

>Is there a function that will display 0 if the column is
null and 1 if
>it is not?
>.


 
 
 

ISNULL varient that will display one value if null and one value if not

Post by David Porta » Sat, 27 Sep 2003 23:39:32


Use CASE:

CASE WHEN col IS NOT NULL THEN 1 ELSE 0 END

But an interesting alternative for numeric values only is to use the
ISNUMERIC function which has the peculiarity that it doesn't propagate
NULLs:

ISNUMERIC(col)

I would recommend the CASE option though as more standard and intuitive.

--
David Portas
------------
Please reply only to the newsgroup
--


Quote:> I am looking for a varient of isnull function that will allow me to
> display 0 if the column is null and 1 if it is not.

> Is there a function that will display 0 if the column is null and 1 if
> it is not?