Sumif for function over range, does that exist?

I have the date in column (e.g., sorted in ascending order), the expense in column B, and I want the sum of all expenses from the same year in column C. For example, if I had determined the year from column A in column D (e.g., d384=year(a384)), I would write sumif(d$2:d384;d384;b$2:b384). I would like to…