I wasn’t reading the panels closely enough but I see the pattern now. The last digits of each row in the second panel are 0, 1, 2, 3, 4, 5. The full values in the second panel are the first occurrence in the first panel ending with that digit.
Apologize for not posting any script. I tried different options but they did not work, that’s why I posted what I was trying to get. I will really appreciate if you could help me with any suggestion.
By the way, as you said that is exactly what I wanted to explain.
My “spidey sense” tells me that there is a deeper problem that led to this requirement, and that you’d be better off addressing that. I don’t think it does anyone a favor to treat this as routine housekeeping. Helping people clean up messes generally leads to more messy code/data. We’ve all had to go through stuff like this but eventually learn that it’s far better to avoid the “messed up” data trees in the first place.