Subject Re: Query Question... but, hard one
Author Svein Erling
--- In firebird-support@yahoogroups.com, "Tanz Anthrox" wrote:
>
> I wrote a SP for this
> and I used your Query
>
> > SELECT T1.Name, T1.Amount, T2.Name, T2.Amount
> > FROM Table T1
> > FULL JOIN Table T2 on T2.IONo = T1.IONo
> > WHERE T1."Type" = 'Outcome' AND
> > T2."Type" = 'Income'
>
> BUT.. I have 7 rows in T1 (Outcome) and 10 rows in T2 (Income)
>
> The Result set of this Query consists of 7 rows.
>
> How can I achieve this....

Sorry, I never use FULL JOIN and didn't know they were this demanding.

Try

SELECT T1.Name, T1.Amount, T2.Name, T2.Amount
FROM Table T1
FULL JOIN Table T2 on T2.IONo = T1.IONo AND
T1."Type" = 'Outcome' AND
T2."Type" = 'Income'
WHERE T1."Type" = 'Outcome' OR
T2."Type" = 'Income'

I think this should work, but haven't quite figured out why.

Set