@Patrick wrote: @Haikuo I believe if you don't select the earliest return date which satifies condition "_date >= Transaction_Date" then you are at risk to miss some returns. Consider the following: Rec_No Customer_Id Transaction_Date Amount Sales_Credit 1 1 1-Nov-15 5 1 2 1 2-Nov-15 5 2 3 1 3-Nov-15 5 1 4 1 4-Nov-15 5 2 If you use record 4 to remove record 1 then the pair record 2/record 3 won't satisfy condition "_date >= Transaction_Date" and you'll miss the removal of record 3. @Patrick, Thank you for your following up and your point is well taken. However, if OP unfortunately has data like that, the problem is beyond a simple code fix. Surely you will have your 'balance sheet', but you will never know if paired transations are the actual pairs without more information. If the purpose is just to get the net 'balance', then the condition of '_date >= Transaction_Date' can be completely ignored. Given the data as is, my approach is to get as far as the 'known' can stand, and stop right at the point where 'unknown' starts. Just my 2cents, Haikuo
... View more