Combine morethan 2 duplicate rows and sum the value

how to combine morethan 2 duplicate rows and sum the value in html table

Why not combine them in the Invoice before printing?