Subject Re: [firebird-support] Re: summation of two select
Author Paul Vinkenoog
Hello Ed,

> Thank you for your respohse. I have not seen Coalesce before.

It was introduced in Firebird 1.5. For details, see http://www.firebirdsql.org/refdocs/langrefupd15-coalesce.html

> Firebird 1.5 balks at the "Select" in the 3rd line "Token unknown, line 3, char 5."
>
> > SELECT
> > COALESCE( PI.Balance,0) + COALESCE(
> > SELECT(PAI.Balance) FROM PersonActInfo PAI where PAI.Person_ID
> ^^^^^^

It may work with a pair of parentheses around the subselect:

SELECT
COALESCE(PI.Balance, 0)
+
COALESCE((SELECT(PAI.Balance) FROM PersonActInfo PAI where PAI.Person_ID = PI.Person_ID), 0)
as Balance
FROM PersonInfo PI
WHERE PI.Person_ID = 154

In 2.5 it should also work without that, I think.


Cheers,
Paul Vinkenoog