🕵️♀️ Task
You can calculate the sum of values in a particular column within a collection with .sum. It returns a single value (Integer or Float).
.sum
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 sum of ages for all users
User.all.sum(:age) => 4566
Calculate the sum of prices for all dishes
Dish.all.sum(:price) => 232