**1 Answer**

written 5.1 years ago by |

SQL provides various aggregate functions which can summarize data of given table.

Sid | SName | Marks |
---|---|---|

1 | John | 90 |

2 | Martin | 80 |

3 | Carol | 89 |

4 | Jack | 99 |

5 | Rose | 88 |

6 | Mary | 90 |

**1.COUNT()**

• This function is used to calculate number of rows in a table selected by query.

• COUNT returns the number of rows in the table when the column value is not NULL.

**Example:**
Find total number of students

SELECT COUNT(Sid) as COUNT

FROM Exam_Marks

Count |
---|

6 |

**2.SUM()**

•This function is used to calculate sum of column values in a table selected by query.

**Example:**

Find total of marks scored by all students

SELECT SUM(Marks) as SUM

FROM Exam_Marks

Sum |
---|

446 |

**3.AVG()**

• This function is used to calculate the average of column values in a table selected by query.

• This function first calculates sum of columns and then divide by total number of rows.

**Example:**

Find average marks of students

SELECT AVG(Marks) as AVG

FROM Exam_Marks

AVG |
---|

89.33 |

**4.MIN()**

•This function is used to find maximum value out of column values in a table selected by query.

**Example:**

Find total of marks scored by all students

SELECT MIN(Marks) as MIN

FROM Exam_Marks

MIN |
---|

80 |

**5.MAX()**

•This function is used to find maximum value out of column values in a table selected by query.

**Example:**

Find total of marks scored by all students

SELECT MAX(Marks) as MAX

FROM Exam_Marks

MAX |
---|

99 |