Subject Re: [firebird-support] SUM function returns NULL if no Records, Need it to return 0
Author Robert martin
Hi

HAVING
SUM(COALESCE(Amount, 0)) > 0


Rob Martin
Software Engineer

phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com

Wild Software Ltd



Anthony Tanas wrote:
> Hi,
>
> I have a query where I am using a HAVING clause, such as:
>
> HAVING
> SUM(AMOUNT) > 0
>
> But the problem is if there are no records tabulated in the aggregate
> function the function returns NULL. This prevents records from being
> fetched. I need it to return 0. What should I do?
>
> Thanks.
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>