22.Group Functions

SQL
  1. Group functions

Group functions : Functions which are acting on mutiple rows

sql> SQL> select sum(sal) from emp;

SUM(SAL)

160200

SQL> select avg(sal) from emp;

AVG(SAL)

 26700

SQL> select count(*) from emp;

COUNT(*)

     6

SQL> select max(sal) from emp;

MAX(SAL)

 56000

Query: to find the name,sal of a employee who is getting max sal

SQL> select ename,sal from emp where sal = (select max(sal) from emp);

ENAME SAL


SHEKAR 56000

SQL> select count(*),sum(sal),avg(sal),max(sal),min(sal) from emp;

COUNT(*) SUM(SAL) AVG(SAL) MAX(SAL) MIN(SAL)


     6     160200      26700      56000      12000