SQL Aggregate Functions

tutorial and example
tutorial and example

Max() Function

The Max() function returns the maximum value of specified column.

Syntax:

Select Max(column_name)

From table_name;

Example:

Select Max(salary)

From teacher;

Min() Function

The Min() function returns the minimum value of specified column.

Syntax:

Select Min(column_name)

From table_name;

Example:

Select Min(salary)

From teacher;

Sum() Function

The Sum() function is used to perform addition on specified column.

Syntax:

Select sum(column_name)

From teacher;

Example:

Select sum(teacher_id)

From teacher;

 

Avg() Function

The Avg() function is used to return the average of specified column.

Syntax:

Select Avg(column_name)

From table_name;

Example:

Select avg(teacher_id)

From teacher;

Count() Function

The Count() function returns the number of records in specified column. It returns number of records from table when user uses * instead of column name.

Syntax:

  1. SELECT count(*)

FROM table_name;

  1. SELECT count(column_name)

FROM table_name;

Example:

  1. Select count(*)

From teacher;

  1. Select count(contact_no)

From teacher;