I have a database with 6500 players and each player has an average of 15 game results.
players
results
Use case
I want to generat
You should be able to use something like this:
class Player scope :order_by_prize, joins(:results).select('name, sum(results.prize) as total_prize').order('total_prize desc')
Refer rails api - active record querying for details.