Rails advanced queries with join and sum calculation
- by Dustin Brewer
I have two models: companies and expenses. Companies have many expenses and expenses belong to companies. My expense model has an 'amount' column.
I was wondering if there is a way to perform a find based on a date range and the amount column of the expenses. Something like top 3 companies by total expense amounts over a 7 day period.
I've tried…