DBMS | GROUP Functions | Exp - 6
GROUP /Aggregate Functions
Group functions are built-in SQL functions that operate on groups of rows and return one value for the entire group.
These functions are:
1. COUNT:
This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition. If the WHERE condition is not specified, then the query returns the total number of rows in the table.
SELECT COUNT (*) FROM employee
WHERE dept = 'Electronics';
WHERE dept = 'Electronics';
2. DISTINCT:
This function is used to select the distinct rows.
SELECT DISTINCT dept FROM employee;
3. MAX():
This function is used to get the maximum value from a column.
SELECT MAX (salary) FROM employee;
4. MIN():
This function is used to get the minimum value from a column.
SELECT MIN (salary) FROM employee;
5. AVG():
This function is used to get the average value of a numeric column.
SELECT AVG (salary) FROM employee;
6. SUM():
This function is used to get the sum of a numeric column.
SELECT SUM (salary) FROM employee;
No comments: