Subject | RE: [firebird-support] summation of two select |
---|---|
Author | Leyne, Sean |
Post date | 2011-04-07T23:40:18Z |
Ed,
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
> I have two select statements that I need one some from. This gets me twoThis should work:
> 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?
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