9 Apr
2010
9 Apr
'10
7:58 p.m.
On Fri, 9 Apr 2010 13:49:43 -0300 "Neil Coghlan" <neil@esl-lounge.com> wrote:
I am trying to print the number of downloads a user's attachments have produced and am 95% there. I just don't know how to print zero if the SUM returns nothing.
I'd check why a sum() is returning null before casting in php. sum() is going to return a 0 if NO record was returned. That means there is at least one count that is null (and some may not be), a null in a sum is enough to nullify the sum. 10 + null = null. select sum(coalesce(count, 0))... You'd be better to set default 0 on files_download.count and update the null record to 0. -- Ivan Sergio Borgonovo http://www.webthatworks.it