Aggregate function (SQL function)

Aggregate function 



Aggregate function is used to perform calculation on group of rows and return the calculated summary like sum of salary, average of salary etc. Available aggregate functions are – 

1. SUM()  

Select SUM(salary) from emp;

2. AVG()

Select AVG(salary) from emp;

 3. COUNT() 

Select COUNT(salary) from emp;

4. MAX()

Select MAX(salary) from emp;

 5. MIN()

Aggregate function 



Aggregate function is used to perform calculation on group of rows and return the calculated summary like sum of salary, average of salary etc. Available aggregate functions are – 

1. SUM()  

Select SUM(salary) from emp;

2. AVG()

Select AVG(salary) from emp where dept=‘sales’;

Select AVG(salary) from emp;

 3. COUNT() 

Select COUNT(salary) from emp;

4. MAX()

Select MAX(salary) from emp where dept=‘Sales’; 

Select MAX(salary) from emp;

 5. MIN()

Select MIN(salary) from emp;

Select MIN(salary) from emp where dept=‘IT’; 

 6. COUNT(*) 

Select count(*) from emp;



SELECT SUM(SAL) FROM EMP GROUP BY DEPT;

 SELECT JOB,SUM(SAL) FROM EMP GROUP BY DEPT; 

SELECT JOB,SUM(SAL),AVG(SAL),MAX(SAL),COUNT(*) EMPLOYEE_COUNT FROM EMP;

Post a Comment

0 Comments