Web | This Site

Learning Ruby on Rails 2.1
Advanced Ruby on Rails 2.1
Ruby on Rails Quick Guide
Ruby Tutorial
Ruby on Rails Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Ruby on Rails 2.1 - The Maths Functions

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.

    Person.average :age

Following will return maximum age of the employee.

    Person.maximum :age

Following will return minimum age of the employee.

    Person.minimum :age

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.

    Person.count

Check the following link for more detail on Calculation Functions

Advertisement

Online Image Processing

Indian Baby Names