MySQL Aggregate Functions With Example

by Geethalakshmi 2010-09-29 15:11:34

MySQL Aggregate Functions With Example


AVG()
Returns the average of the parameter passed. Returns 0 if no matching rows found.

Example:
Avg(salary)

COUNT()
Counts the number of NON NULL values of the parameter passed. Returns 0 if no matching rows found.

Example:
Select employee_id, COUNT(*) from table_name;

MAX()
Returns the maximum value of the parameter passed. Returns 0 if no matching rows found.

Example:
Select MAX(employee_salary) from table_name

MIN()
Returns the minimun value of the parameter passed. Returns 0 if no matching rows found.

Example:
Select MIN(employee_salary) from table_name

SUM()
Returns the sum of the parameter passed. Returns NULL if no matching rows found.

Example:
Select SUM(employee_salary) from table_name

Tagged in:

1058
like
0
dislike
0
mail
flag

You must LOGIN to add comments