Summing rows if other column has duplicate values

in general we can do it by grouping the data and processing the group members