Thanks for all your responses. I went with the coalesce way - it works like a
charm.
Thanks again!
Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-0001 Office
(516) 480-1870 Mobile/Emergencies
(516) 908-4185 Fax
http://www.meitech.com/
--
MySQL General Mailing List
F
"Jay Blanchard" <[EMAIL PROTECTED]> wrote on 12/16/2004
01:00:00 PM:
> [snip]
> Is there any way to make sum() return "0" instead of "NULL" when one or
> more of the rows being sum()'d is null?
>
> Phrased another way, is there a way to make mySQL treat "NULL" as "0"
> when dealing with mathemat
>Is there any way to make sum() return "0" instead of "NULL" when one or
>more of the rows being sum()'d is null?
>
>Phrased another way, is there a way to make mySQL treat "NULL" as "0"
>when dealing with mathematical functions?
You can use ifnull
select sum(ifnull(points,0)) from abc;
[snip]
Is there any way to make sum() return "0" instead of "NULL" when one or
more of the rows being sum()'d is null?
Phrased another way, is there a way to make mySQL treat "NULL" as "0"
when dealing with mathematical functions?
[/snip]
Use an IF...
SELECT SUM(IF(myColumn IS NULL, 0, myColumn)
Hi Tim,
I guess you can add something like this
to your statement:
SELECT COALESCE( SUM(column) , 0 ) FROM ...
/Johan
Gustafson, Tim wrote:
Is there any way to make sum() return "0" instead of "NULL" when one or
more of the rows being sum()'d is null?
Phrased another way, is there a way to make myS
Is there any way to make sum() return "0" instead of "NULL" when one or
more of the rows being sum()'d is null?
Phrased another way, is there a way to make mySQL treat "NULL" as "0"
when dealing with mathematical functions?
Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-