Subject Re: Need some SQL help
Author Svein Erling
> The data sample (there may be more than one pair of OB/CB, because
> of different currencies).

Hooray Riho-Rene, you may have several pairs per day, but only one pair for each currency on that day. That was the bit that was needed to write this statement:

SELECT SDATE, CURRENCY
FROM STATEMENT S1
WHERE S1.OPTYPE = 'OB'
AND NOT EXISTS(SELECT * FROM STATEMENT S2
WHERE S2.SDATE = S1.SDATE
AND S2.CURRENCY = S1.CURRENCY
AND S2.OPTYPE = 'CB')

Of course, this will take a little bit of time to run.

HTH,
Set