Krivalar Tutorials 
Krivalar Tutorials



SQL Aggregate Functions - MIN, MAX, AVG, COUNT, SUM

<< Previous - SQL SELECT TOP

Next - SQL MIN() Function>>






SQL aggregate functions are used to perform calculations against a set of values and return a single value as a result. Aggregate functions are often used in the SELECT statement and also with the GROUP BY and HAVING clauses.

Commonly used aggregate functions are:

FunctionMeaning
MIN()gives the lowest value from the set of values in the selected column.
MAX()gives the highest value from the set of values in the selected column.
COUNT()count the number of rows in the particular column.
AVG()find the average of a set of values in the particular column.
SUM()sum up all the rows in the selected column.

Now, let us discuss these functions one by one with an example.

For all examples consider the below demo student_mark table from collegedb database.

mysql> SELECT * FROM Student_Mark;
+--------+---------+-----------+------+
| RollNo | Name    | City      | Mark |
+--------+---------+-----------+------+
|    101 | Sakthi  | Chennai   |   80 |
|    102 | Bala    | Chennai   |   86 |
|    103 | Chandra | Bangalore |   89 |
|    104 | Madhan  | Goa       |   80 |
|    105 | Jose    | Kerala    |   82 |
|    106 | Jithu   | Kerala    |   85 |
|    107 | Veni    | Bangalore |   85 |
+--------+---------+-----------+------+
7 rows in set (0.00 sec)

<< Previous - SQL SELECT TOP

Next - SQL MIN() Function>>









Searching using Binary Search Tree