I have the following simplified table in sql server:
PartyID LicensePlate    Amount
123 XVE158          10
123 VSE587          20
128 XVE158          30
128 VES874          80
158 TYU684          20
158 VTI267          60
356 VES874          30
356 BNU673          20
356 AAH637          60
Now I want to make a summation of the column Amount with every PartyID that has a common LicensePlate. PartyID 123 and 128 have LicensePlate XVE158 in common. PartyID 128 and 356 have LicensePlate VES874 in common. PartyID 123 and 356 have no LicensePlate in common but I still want them in the same group as they are linked togetter with PartyId 128. As an end result I would like to have a column that gives back all the distinct LicensePlates with this logic with the total amount. So for this example that would be:
LicensePlates                               Total Amount
XVE158, VSE587, VES874, BNU673, AAH637      250
TYU684, VTI267                              80
I have never tried to do this sort of a summation before so I have no idea where to start.
 
     
    