Thursday, October 23, 2008

SQL Aggregate Functions

Most commonly used Aggregate Functions:

SUM returns the sum of values of expr.
EX:select SUM(sal) from emp;Output gives the sum of all salaries in emp table.

AVG returns average value of expr.
EX:select AVG(salary) from employees;Output gives average of all salaries.

COUNT returns the number of rows returned by the query.
EX:select COUNT(*) from emp;Output returns the number of rows in emp table.

MAX returns maximum value of expr.
EX:select MAX(salary) from emp;Output gives the maximum salary in emp table.

MIN returns minimum value of expr.
EX:select MIN(salary) from emp;Output gives the minimum salary in emp table.

No comments:

Post a Comment

Disclaimer