Friday, October 28, 2011

ORACLE SQL TUTORIAL: GROUP FUNCTIONS


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;





0 Responses to “ORACLE SQL TUTORIAL: GROUP FUNCTIONS”

Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.