I've assigned these rows to hashes:
other_id: 1,amount: 9290,id: 1
other_id: 2,amount: 2262,id: 1
other_id: 3,amount: 9588,id: 2
other_id: 4,amount: 1634,id: 2
How do I add together the amount
values for a specific id
, so for id: 1
, I need the total = 9290 + 2262
?
Even better, if I had a large collection of these, how would I write code so that it would find the id number with the maximum value of total if total is the sum of all amount instances for a specific id number?