Subject Re: [firebird-support] Re: Sub query returns NULL
Author Lester Caine
Moegamat Alexander wrote:
> Hi
> It seems by adding another coalesce seems to do the trick ... question is
> why
> Sub query
> coalesce((select *coalesce(a.CreditSales,0)*
> FROM crdsales_v a
> where a.salesdate = z.salesdate),0) as CreditSales,

For the reason already stated. The sub-select will not return anything if there
are no records to return, so the sub-select is null, not the 'value returned'.
You wanted 'if nothing returned ... then 0' which is the outer coalesce. The
INNER one is probably redundant?

Lester Caine - G8HFL
Contact -
L.S.Caine Electronic Services -
EnquirySolve -
Model Engineers Digital Workshop -
Firebird -