Copyright © 2014 by tutorialspoint
Consider a table object called Person. This table is having fields like age, first_name, last_name and salary.
Following will return average age of all the employee.
Following will return maximum age of the employee.
Following will return minimum age of the employee.
Follwoing will return sum of salaries of all the employees.
Person.sum :salary, :group => :last_name
Following will count the number of records having age more than 26.
Person.count(:conditions => "age > 26")
Following count total number of records.
Check the following link for more detail on Calculation Functions