• Yes it does match what I want as output.

    However the trouble is, these child codes are common codes for various other parent codes.

    For example two different parents can share the same child codes and I have to find out which child code belongs to which parent and the only way i can do is through the account no because account nos will be different for each set of parent and child.

    Am I clear this time? sorry to confuse you