Professional Documents
Culture Documents
Aggregate Functions: Fundamentals of SQL
Aggregate Functions: Fundamentals of SQL
1. avg():
Returns average value of a specified column.
Used only for numeric datatype.
2. min():
Returns lowest value of a specified column.
3. max():
Returns highest value of a specified column.
4. sum():
Returns addition of all the values in a specified column.
5. count():
counts the number of rows in a specified column.
Fundamentals Of SQL
Consider the following table for Examples:
StudentID Name DeptID Marks
1 Alice 101 55
2 Bob 102 34
3 Rachel 103 67
4 Carry 104 45
5 Skye 105 64
Examples:
1. select avg(Marks)
from Student;
Output: avg(Marks)
53
2. select min(Marks)
from Student;
Output: min(Marks)
34
3. select max(Marks)
from Student;
Output: max(Marks)
67
Fundamentals Of SQL
4. select sum(Marks)
from Student;
Output: sum(Marks)
265
Output:
count(Marks)
5
Fundamentals Of SQL