## SQL aggregate function

SQL aggregate function allows the user to operate on a set of values and is the built in functions. Aggregate functions which take a collection ( A set or multi set ) of values as input and return a single value.

**There are five built in***SQL aggregate*functions:1.Average: avg

2.Minimum: min

3.Maximum: max

4.Total: sum

5.Count: count

The input to sum and avg must be a collection of numbers, but the other SQL operators can operate on non-numeric data types such as string, as well.

We write the query as follows.

**“Find the average balance at SARAWATHIPURAM branch”**We write the query as follows.

*Select avg (balance) from account*

*Where br_name = “SARAWATHIPURAM ”*

To find the number of rows in a table, we use count function.

**“Find the total number of customers of the bank”**

*Select count(*)*

*From customer.*

**Similarly to find the maximum balance in SARAWATHIPURAM branch, we will write the query as follows.**

*Select max (balance) from account*

*Where br_name = “SARAWATHIPURAM”*

**To find the minimum balance of a particular branch,**

*Select min(balance) from account*

*Where br_name = “SARAWATHIPURAM”*