0% found this document useful (0 votes)
15 views

Exercise 5 - Group Functions

The document contains examples of SQL group functions to find minimum, maximum, average, count and other aggregate values for groups of employees by job, salary, department and more.

Uploaded by

Faqihah Syazwani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Exercise 5 - Group Functions

The document contains examples of SQL group functions to find minimum, maximum, average, count and other aggregate values for groups of employees by job, salary, department and more.

Uploaded by

Faqihah Syazwani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Exercise 5: Group Functions

1. Find the minimum salary of all employees.

SELECT MIN(SAL) AS MINIMUM

FROM EMP;

2. Find the minimum, maximum, and average salaries of all employees.

SELECT MIN(SAL) AS MINIMUM,

ROUND(AVG(SAL),2) AS AVERAGE,

MAX(SAL) AS MAXIMUM

FROM EMP;

3. List the minimum and maximum salary for each job type.

select JOB, MIN(SAL), MAX(SAL)

FROM EMP

group by JOB;
4. Find out how many managers there are without listing them.

select COUNT(*)

from EMP

where JOB='MANAGER';

5. Find the average salary and average total remuneration for each job type. Remember
salesmen earn commission.

select JOB, ROUND(AVG(SAL),2) AS "AVERAGE SALARY", ROUND(AVG(SAL+NVL(COMM,0)),2)


AS "AVERAGE RENUMERATION"

from EMP

GROUP BY JOB;
6. Find out the difference between highest and lowest salaries.

7. Find all departments which have more than 3 employees.


8. Check whether all employee numbers are indeed unique.
9. List lowest paid employees working for each manager. Exclude any groups where the minimum
salary is less than 1000. Sort the output by salary.

You might also like