Reputation: 2794
Outside of using a raw SQL query, is there a nice way to divide an active record query result by a constant? A variable?
Example:
Phones.group(:year).order(:year).average(:talk_time_min)
If I wanted to retrieve the talk_time_min
in seconds, how could I do talk_time_min / 60
?
Upvotes: 0
Views: 167
Reputation: 44601
Like this:
Phones.group(:year).order(:year).average('talk_time_min/60')
Upvotes: 1