Michel,
>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
000003000003 000003
000004 000002
000005 000002
000006 000003