I have a table:
ID GroupID Contact Subject Score
10 32 8017 5 77
11 15 5019 1 80
12 32 8018 3 62
13 17 8870 9 63
14 49 8018 11 72
15 19 8305 7 93
16 22 8029 11 88
I wish to get the sum of Score of each ID as long as there is a common value among each of the 3 fields GroupID, Contact and Subject, as well as the common IDs.
For instance,
- ID
10is linked to ID12as they have the sameGroupID. - ID
12is subsequently linked to ID14as they have the sameContact. - ID
14is subsequently linked to ID16as they have the sameSubject. - Therefore, the
Sum_Scoreof IDs10,12,14and16= 77 + 62 + 72 + 88 = 299
Output:
ID GroupID Contact Subject Score Sum_Score Common_IDs
10 32 8017 5 77 299 (10, 12, 14, 16)
11 15 5019 1 80 80 (11)
12 32 8018 3 62 299 (10, 12, 14, 16)
13 17 8870 9 63 63 (13)
14 49 8018 11 72 299 (10, 12, 14, 16)
15 19 8305 7 93 93 (15)
16 22 8029 11 88 299 (10, 12, 14, 16)