/    /  DBMS – Mathematical Functions

           Mathematical Functions

                                

There are five mathematical clauses :  

COUNT : Returns the count of rows that align with the given criteria.

SUM : Returns the total sum of a column’s numeric value.

AVG : Returns the average of a column’s numeric value.

Let us consider the following relation :

 

                                             R4 :  FACULTY-1

————————————————————             

FNo FName              DNo Qual           Salary

————————————————————

522 Ria              21   Ph.D.         35000

524 Priya              22   MTech       30000

525 Sia              22   MTech       42000

527 Maggie               23   MTech       28000

530 Alex             23   MTech       32000

533 Ben             24   Ph.D.          33000

535 Becca              24   Ph.D.          32000

537 Justin                25   MTech       26000

539 Pat              25   MTech       24000

540 Jack               25   MTech       34000

————————————————————

Example-1 :  Find the number of employees drawing more than 30,000.

Select count (*)

                                 From  FACULTY-1

                                 Where Salary >30000 ;

                                                                    

                                 Output  : 6                                

 

Example-2 :  Find the sum of the salaries of all employees.

 

                                                                Select sum (salary)

                                 From  FACULTY-1 :

                                                                    

                                 Output  :  316000

 

Example-3 :  Find the avg of salary for all employees.

 

                                                                Select avg (salary)

                                 From  FACULTY-1 ;

                                                                    

                                 Output  :  31600

REFERENCE

               Mathematical Functions