# SQL - Aggregate Functions

## What are Aggregate Functions?

Aggregate Functions work on the calculation on a set of values and return a single value. we often use aggregate functions with the GROUP BY and HAVING CLAUSE of the SELECT statement.

The following Various Aggregate Functions:-
• AVG
• COUNT
• MIN
• MAX
• SUM

## AVG

The AVG() function is used to return the average value of n.

Syntax:-
```
SELECT  AVG (column_name)FROM table_nameWHERE conditions;```
Example: Let's see how to use AVG function in the table.

Query :

```
SELECT  AVG (Salary)
FROM customers;
```
Output :

Now, you can see AVG() Function calculated average salary in the salary column.

## COUNT

The  COUNT() function is used to returns the number of rows.

Syntax:-
```

SELECT  COUNT (column_name)

FROM table_name

WHERE conditions;

```
Example: Let's see how to use the COUNT function in the table.

Query:

```

SELECT  COUNT (Salary)

FROM customers

WHERE Customer_Id = 4;

```
Output :

Now, you can see COUNT() Function calculated number of row in the salary column.

## MIN

The  MIN() function is used to returns the minimum value.

Syntax:-

```

SELECT  MIN (column_name)

FROM table_name

WHERE conditions;

```
Example: Let's see how to use MIN function in the table.

Query :

```

SELECT  MIN (Salary)

FROM customers;

```
Output :

Now, you can see MIN() Function calculated minimum salary in the salary column.

## MAX

The  MAX() function is used to returns the maximum value.

Syntax:-

```

SELECT  MAX (column_name)

FROM table_name

WHERE conditions;

```
Example: Let's see how to use the MAX function in the table.

Query :

```

SELECT  MAX (Salary)

FROM customers;

```
Output :
Now, you can see MAX() Function calculated maximum salary in the salary column.

## SUM

The  SUM() function is used to returns the sum of the column.

Syntax:-

```

SELECT  SUM (column_name)

FROM table_name

WHERE conditions;

```
Example: Let's see how to use the SUM() function in the table.

Query :

```

SELECT  SUM (Salary)

FROM customers

WHERE Customer_Id = 5;

```
Output :

Now, you can see SUM() Function calculated the sum of the column in the salary column.