- Aggregate functions are those functions that can be apply on multiple rows and returns signal result for all rows.
- They are also known as grouping functions.
- Oracle provides the following aggregate function.
Sum()
- It return sum of all given values.
- Syntax
sum (val1, val2, …. Val n)
SELECT sum ( 10, 20, 30 ) FROM DUAL ;
60
SELECT sum ( salary ) FROM emp;
1,20,000
Max ()
- It returns maximum value from a given set of value.
- Syntax:
max (val1, val2, ..., valN);
SELECT max ( 10, 20, 30 ) FROM DUAL ;
30
SELECT max ( salary ) FROM emp ;
20,000
Min ()
- It returns minimum value from a given set of value.
- Syntax:
min (val1, val2, ..., valN);
SELECT min( 10, 20, 30 ) FROM DUAL ;
10
SELECT min( salary ) FROM emp;
5000
Avg ()
- It returns average value from a given set of value.
- Syntax:
avg ( value1, value2, ..., valueN ) ;
SELECT avg ( 10, 20, 30 ) FROM DUAL;
20
Count ()
- It returns total number of records of the database table.
- It has two form as follow.
- count (*):
- it count total no of records including duplicate records as well as null values.
count (*) ;
SELECT count (*) FROM emp;
35
- count <expr>:
- it counts total number of records excluding null values.
- Syntax:
count (expr) ;
SELECT count (emp_no) FROM emp;
30