Multiple Row Function – Group Function in SQL
Multiple Row Function :
- Multiple row function is also called as group function or it is also called as aggregate function.
- group function operate on set of rows to give one result per group
Types of Group Function :
- AVG – average value of number of rows in a table, it ignoring null value
- COUNT – number of rows( count all selected rows using * , including duplicates and rows with null value )
- MAX – maximum value of expression, ignore null values
- MIN – minimum value of expression, ignore null values
- SUM – sum of values of number of rows in a table, it ignore null values
Example :
Question : Display the total salary in employee table
Query : SELECT SUM( sal ) as total FROM emp;
Question : Display Average salary in employee table
Query : SELECT AVG( sal ) as average FROM emp;
Question : Display Min and Max salary in employee table
Query : SELECT MIN( sal ) as minsal MAX( sal ) as maxsal FROM emp;
Question : Display total count of rows in employee table
Query : SELECT COUNT( * ) as average FROM emp;