🕵️♀️ Task
You can calculate the average value in a particular column within a collection with .average. It returns a single value (Integer or Float).
.average
Integer
Float
LevelUp
Selecting all records
Find one record by primary...
Counting records
Find record via index
Find record by position us...
Order records by column va...
Retrieving values from col...
Retrieve all values from a...
Limit number of selected r...
Offset selected records
Filtering records with whe...
Exclude records from result
Calculate minimum value in...
Calculate maximum value in...
Calculate average value in...
Calculate sum of values in...
Find the "many" side of a ...
Find the "one" side of one...
Many-to-many associations ...
0.0% complete
Calculate the average age for all users
User.all.average(:age) => 27
Calculate the average price for all dishes
Dish.all.average(:price) => 5.69