>>Now, what if I need to extract the minimum value between the primary key and the secondary key. Because, on some results, it may be that the result includes a record which is having the secondary key higher than the primary key.
>
>You lost me here. What result do you want if we change your first example to this:
>
>000001 000002
>000002
000003>000003 000003
>000004 000002
>000005 000002
>000006 000003
I may have a result like this:
000001 000002
000032 000003
000034 000003
000004 000002
000005 000002
000056 000003
So, the final result should be:
000001 000002
000003 000003