«Back to Home

Oracle Jump Start

Topics

How To Use Group Function in Oracle

Group Function
 
Group functions are those statistical functions, which gives information about a group of value taken as whole.
  • COUNT
  • SUM
  • MAX(column name)
  • MIN(column name)
  • AVG([DISTINCT | ALL] column name)
COUNT
 
Count function determines the number of rows or NON NULL columns value. If * is
passed, the total number of rows is returned.

Example
  1. Select COUNT(*) from Employee;  
1
  1. Select count (DISTINCT Emp_ Job) from employee;  
2

SUM
 
This function returns the sum of values for the select list columns.

Example
  1. Select SUM(salary) From employee;  
3

MAX
 
This function return the maximum value of the selected list of item.

Example
  1. Select MAX(salary) from employee  
  2. Where Emp_job = ‘salesman’;  
4

MIN
 
This function returns the minimum value of the selected list of items.

Example
  1. Select MIN(SALARY) from Employee;  
5

AVG([DISTINCT | ALL] column name)
 
This function returns the average salary and number of column value.

Example 
  1. Select AVG(salary) , COUNT(*) from employee  
  2. where dept_no = 102;  
6

Summary
 
Thus, we learnt, group functions are those statistical functions, which gives information about a group of value. There are some types of group function such as Count, Sum, Max, Min, Avg. We learnt, how to use these group functions in Oracle with the examples.