What Are Group Functions?
Group functions operate on sets of rows to give one result per group
Types of Group Functions
Group function syntax
SELECT group_function(column), ... FROM table [WHERE condition] [ORDER BY column];
- It is used to count the no of records in a column
- COUNT(*) returns the number of rows in a table
Query: Count the number of employee working in department number 80
SELECT COUNT(*) FROM employees WHERE department_id=80; Result value:34
note:COUNT(expr) returns the number of rows with non-null values
SELECT COUNT(commission_pct) FROM employees WHERE department_id = 80; Result value: 3
- It is used to find the average value of the column.
Query: find the average salary of employees who are working in department number 80
SELECT AVG(salary) FROM employees where department_id=80
- It is used to find max value in column
Query: Display the max sal of the employee table?
SELECT MAX(salary) FROM employees;
- It is used to find minimum value in the column.
Query: Display the minimum salary of the employee table?
SELECT MIN(salary) FROM employees;
- It is used to find the summation of all the values within the column
Query:find the sum of all the salary of employees table
SELECT SUM(salary) FROM employees;