Created
February 17, 2016 07:27
-
-
Save abrarShariar/56b795da4754e3083bbc to your computer and use it in GitHub Desktop.
solution to aggregate functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Aggregate Function | |
| 1. Find the maximum,minimum, average salary and also the number of employees assigned to department 20. | |
| >> select max(sal),min(sal),avg(sal),count(empno) from emp where deptno=20; | |
| 2. Find the maximum,minimum, average salary and also the number of employees employed under designation ‘Salesman’. | |
| >> select max(sal),min(sal),avg(sal),count(empno) from emp group by job having job='SALESMAN'; | |
| 3. Find the maximum,minimum, average salary and commission for employees those who have at least 0 commission. | |
| >>select max(sal),min(sal),avg(sal),comm from emp group by comm having comm>=0; | |
| 4. Find out the number of employees from each department. | |
| >> select count(ename) from emp group by deptno; | |
| 5. Find out the average number of employees in each department. | |
| >> select avg(count(ename)) from emp group by deptno; | |
| 6. Find the minimum and maximum joining date for each department according to their job. | |
| 7. Count how many employees get no commission | |
| >> select count(ename) from emp where comm is null; | |
| 8. Calculate and show average commission of all the employees working in the institute0 | |
| >> select avg(comm) from emp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment