How do you define "incremental"? Are you looking for a difference of certain number between 2 consecutive records? Also, please use code tags to keep alignment of your sample input data. What is the field size for both the fields (abcdef and 1234)?
The reason abcdef123456 is only selected is that abcd1234 and abcd12345 are already present in the record abcdef123456.
I have to select a record which is the superset of all the existing records and discard all the other records which are a subset of any existing record.
By the same logic since cdef4 is already contained in cdef456, it was not selected.
since I understood Your question no reason to address me personally,
but You! did You read and understand my reply ? looks like not
as I said before we have the requirement that ..
since we answer on our own time and at no charge I feel that we are entitled
to a proper explanation of the business need for such a nonsense
in other words ...
when You hire a paid <consultant> You have the right to ask him/her to do something without explanation
since we answer on our own time and at no charge we are entitled to some respect and not be treated like children and bossed around
You should feel at least the ethical duty of telling the reason for the requirement
if You are not prepared to do so, You should not ask help on a forum
also explaining the business requirement might help to find a better description and definition of the technical aspects of the requirement