Assuming that you use Microsoft Excel you have to use SUMIF function:
=SUMIF(B1:B9,A1,C1:C9)
Of course, according to your language version and regional settings above function can have localized name and instead of commas there might be semicolons required.