I have a table that contains the data as below
AccountNo Code Date 123456 OpenCS 01/12/2013 123456 CloseCS 03/12/2013 123456 CALLIN 11/10/2013 123456 CloseCS 08/08/2009 111587 OpenCS 12/12/2013 111587 CloseCS 01/12/2013
What I need to get is all Accounts with a completed OpenCS code but no CloseCS AFTER the OpenCS
So I have 2 selects querys
Select AccountNo, Code, Date FROM tblTrans
WHERE Code = ‘OpenCS’
AND
Select AccountNo, Code, Date FROM tblTrans
WHERE Code = ‘CloseCS’
Where im falling down is joining these to get the required data. Tried a couple of joins but cant get the select to exclude the records.
So with this it would only return account 111587 as the Close was done before the Open.