
- Ruby on Rails Tutorial
- Ruby on Rails - Home
- Ruby on Rails - Introduction
- Ruby on Rails - Installation
- Ruby on Rails - Framework
- Ruby on Rails - Directory Structure
- Ruby on Rails - Examples
- Ruby on Rails - Database Setup
- Ruby on Rails - Active Records
- Ruby on Rails - Migrations
- Ruby on Rails - Controllers
- Ruby on Rails - Routes
- Ruby on Rails - Views
- Ruby on Rails - Layouts
- Ruby on Rails - Scaffolding
- Ruby on Rails - AJAX
- Ruby on Rails - File Uploading
- Ruby on Rails - Send Emails
- Ruby on Rails Resources
- Ruby on Rails - References Guide
- Ruby on Rails - Quick Guide
- Ruby on Rails - Resources
- Ruby on Rails - Discussion
- Ruby Tutorial
- Ruby Tutorial
Ruby on Rails - 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 the average age of all the employees.
Person.average :age
The following will return the maximum age of the employees.
Person.maximum :age
The following will return minimum age of the employees.
Person.minimum :age
The following will return the sum of salaries of all the employees.
Person.sum :salary, :group => :last_name
The following will count the number of records having age more than 26.
Person.count(:conditions => "age > 26")
The following will count the total number of records.
Person.count
Check the Calculation Functions link for more detail on Calculation Functions.
rails-references-guide.htm
Advertisements