List: | General Discussion | « Previous MessageNext Message » | |

From: | Jay Blanchard | Date: | December 16 2004 6:00pm |

Subject: | RE: sum() Function and NULL values | ||

View as plain text |

[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)) AS myTotal FROM myTable

Thread | ||
---|---|---|

• sum() Function and NULL values | Tim Gustafson | 16 Dec |

• Re: sum() Function and NULL values | Johan Höök | 16 Dec |

• Re: sum() Function and NULL values | beacker | 16 Dec |

• RE: sum() Function and NULL values | Jay Blanchard | 16 Dec |

• RE: sum() Function and NULL values | SGreen | 16 Dec |

• RE: sum() Function and NULL values | Tim Gustafson | 17 Dec |