Subject RE: [firebird-support] summation of two select
Author Leyne, Sean
Ed,


> I have two select statements that I need one some from. This gets me two
> values:
>
> select PI.Balance from PersonInfo PI where PI.Person_ID = 154 union select
> sum(PAI.Balance) from PersonActInfo PAI where PAI.Person_ID = 154
>
> but I need one value-the some of those two.
>
> Can that be done in FB 1.5?

This should work:

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


Sean