I have a table defined as such:
Name - Order# - Widget Count
Bob - 12311 - 6
Nancy- 12555 - 8
BoB - 87573 - 12
Nancy- 12929 - 4
I’d like to retrieve them as such:
Bob - 18
Nancy - 12
Ie: A sum of their widget counts, ordered by name. I know how to go about this in SQL server/etc, but I’m not sure what the best practice is in Rails. Any help would be much appreciated!
This should work, assuming your model is called Person:
You can find more info about it on RailsGuides for ActiveRecord.