Practice 5: Maximum Minimum Sum Average
Practice 5: Maximum Minimum Sum Average
Practice 5: Maximum Minimum Sum Average
Determine the validity of the following three statements. Circle either True or False.
1. Group functions work across many rows to produce one result per group.
True/False
2. Group functions include nulls in calculations.
True/False
3. The WHEREclause restricts rows prior to inclusion in a group calculation.
True/False
4. Display the highest, lowest, sum, and average salary of all employees. Label the columns
Maximum, Minimum, Sum, and Average, respectively. Round your results to the nearest whole
number. Place your SQL statement in a text file named lab5_6.sql.
5. Modify the query in lab5_4.sqlto display the minimum, maximum, sum, and average salary for
each job type. Resave lab5_4.sqlto lab5_5.sql. Run the statement in lab5_5.sql.
6. Write a query to display the number of people with the same job.
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
job_id count
SH_CLERK 20
AD_VP 2
PU_MAN 1
IT_PROG 5
ST_CLERK 20
FI_MGR 1
PU_CLERK 5
HR_REP 1
ST_MAN 5
MK_MAN 1
AC_MGR 1
SA_REP 30
AD_ASST 1
PR_REP 1
MK_REP 1
FI_ACCOUNT 5
AC_ACCOUNT 1
7. Determine the number of managers without listing them. Label the column Number of
Managers. Hint:Use the MANAGER_IDcolumn to determine the number of managers.
Number of Managers
19
difference
21900.00
9. Display the manager number and the salary of the lowest paid employee for that manager.
Exclude anyone whose manager is not known. Exclude any groups where the minimum
salary is less than $6,000. Sort the output in descending order of salary.
manager_id min
0 24000.00
102 9000.00
205 8300.00
146 7000.00
145 7000.00
108 6900.00
149 6200.00
147 6200.00
148 6100.00
Human 2400 1
Resources
Purchasing 1700 6
Finance 1700 6
Administration 1700 1
Shipping 1500 45
Accounting 1700 2
Sales 2500 34
Marketing 1800 2
IT 1400 5
Executive 1700 3
11. Create a query that will display the total number of employees and, of that total, the number of
employees hired in 1995, 1996, 1997, and 1998. Create appropriate column headings.