GROUP FUNCTIONS
Ø Sum
Ø Avg
Ø Max
Ø Min
Ø Count
Group functions will be applied on all the rows but produces single output.
a) SUM
This will give the sum of the values of the specified column.
Syntax: sum (column)
Ex:
SQL> select sum(sal) from emp;
SUM(SAL)
----------
38600
b) AVG
This will give the average of the values of the specified column.
Syntax: avg (column)
Ex:
SQL> select avg(sal) from emp;
AVG(SAL)
---------------
2757.14286
c) MAX
This will give the maximum of the values of the specified column.
Syntax: max (column)
Ex:
SQL> select max(sal) from emp;
MAX(SAL)
----------
5000
d) MIN
This will give the minimum of the values of the specified column.
Syntax: min (column)
Ex:
SQL> select min(sal) from emp;
MIN(SAL)
----------
500
e) COUNT
This will give the count of the values of the specified column.
Syntax: count (column)
Ex:
SQL> select count(sal),count(*) from emp;
COUNT(SAL) COUNT(*)
-------------- ------------
14
No comments:
Post a Comment