Subject | Re: Coalesce Help in Stored Procedure |
---|---|
Author | Muthu Annamalai |
Post date | 2004-08-23T17:40:57Z |
--- In firebird-support@yahoogroups.com, Lucas Franzen <luc@r...>
wrote:
I still don't understand, I think I can catch after a while working
with coalesce.
Thanks,
Muthu
wrote:
>table
>
> Muthu Annamalai schrieb:
>
> > Hi Luc:
> >
> > Look into the following Stored Procedure
> >
> > SELECT COALESCE(SUM(AMOUNT),0) FROM RECEIPT
> > WHERE CAST(RECEIPTDATE AS DATE) = :SALESDAY AND
> > PAYMENTID =7
> > INTO :CHECKSALES;
> >
> > This is part of the same stored procedure, this is actually
> > returning zero if there is no matching row in table. Here the
> > is different table, but for given salesday there is no record.Hi,
>
> Yes, but you're using a SUM function here.
>
> This is NOT the same as a plain select.
> The result of SUM itself is initialized with NULL, so the coalesce
> works. ;-)
>
>
> Luc.
I still don't understand, I think I can catch after a while working
with coalesce.
Thanks,
Muthu