My data looks like similar to this: (the picture below is not mine, but describes perfectly my situation)

where the IDs are not unique but for each ID value I have a unique target value The following solution has been suggested:

But sadly that solution does not work with me (I do not have only one table that has duplicate IDs), is there any other way to solve this problem?
PS: I do not whether I should credit from where I took the picture or something like that,just mention it in the comments and I will do it, Thank you.