Tutorials Point


  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

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Ruby on Rails 2.1 - The Maths Functions


previous next AddThis Social Bookmark Button

Advertisements

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



previous next Printer Friendly

Advertisements


  

Advertisements