Subject Re: [ib-support] Join Table with self
Author Svein Erling Tysvær
>I get 7834 records. I should only have the 764.

Yep, that's expected when transref is not unique.

But try

SELECT count(a.transref) as transcount
FROM genledger a
WHERE a.accountid = 'Bank - Sanlam'
AND EXISTS (SELECT 1 FROM Genledger b
WHERE (a.transref = b.transref) AND (b.actn = 'C'))
AND a.actn = 'D'
AND a.transdate between '04/01/2002' and '04/30/2002'

This should yield 764 or less,
Set