Hi Ksharp, Thank you for your reply. In your solution a new id is created, what I'm looking to do is retain the first parent as the group id. For example, company_a is the parent of company_b who is the parent of company_c and company_d. Company a, b,c and d therefore form a group headed by company_a. Have: From_Key To_Key a b b c b d Want: Group_Key To_Key a a a b a c a d You raise a good point in reply to Patrick. In the data there should not be any entity with more than one parent, although there are errors in the data where the relationship between entities has been recorded in error. This results in circular relationships (as Patrick mentions) and entities with 2 or more parents.
... View more