Merge cell contents from different columns into a single row

First of all, sorry for my bad English.

As the title says, I want to combine the content of cells from different columns in a single row so that I get something like the following image.

I think a image will explain better than I could with my words. I hope you can help me.

Have you tried using PivotTable?

=SUMIF($A$1:$A$17;$A19;B$1:B$17)
image

If by chance a person has non-numeric data, they can use INDEX/MATCH with a binary product for multiple criteria to select the desired range (in column A) and then collapse by what is essentially a lookup. Here is a quick example spreadsheet:
CollapseRows.ods (10.0 KB)