David Grof
Practice 4
1. Group functions work across many rows to produce one result per group.
a. True/False
2. Group functions include nulls in calculations.
a. True/False
3. The WHERE clause restricts rows prior
...
David Grof
Practice 4
1. Group functions work across many rows to produce one result per group.
a. True/False
2. Group functions include nulls in calculations.
a. True/False
3. The WHERE clause restricts rows prior to inclusion in a group calculation.
a. True/False
4. The HR department needs the following reports:
Find 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 lab_04_04.sql.
a. SELECT ROUND (MAX(salary),0) "Maximum", ROUND (MIN(salary),0)
"Minimum", ROUND (SUM(salary),0) "Sum", ROUND (AVG(salary),0)
"Average" FROM employees;
5. Modify the query in lab_04_04.sql to display the minimum, maximum, sum, and average
salary for each job type. Resave lab_04_04.sql as lab_04_05.sql. Run the statement in
lab_04_05.sql.
a. SELECT job_id, ROUND (MAX(salary),0) "Maximum", ROUND
(MIN(salary),0) "Minimum", ROUND(SUM(salary),0) "Sum", ROUND
(AVG(salary),0) "Average" FROM employees GROUP BY job_id;6. Write a query to display the number of people with the same job.
a. SELECT job_id, COUNT(*) FROM employees GROUP BY job_id;
Generalize the query so that the user in the HR department is prompted for a job title. Save the
script to a file named lab_04_06.sql.b. SELECT job_id, COUNT (*) FROM employees WHERE job_id = '&job_title'
GROUP BY job_id;
7. Determine the number of managers without listing them. Label the column Number of
Managers.
a. SELECT COUNT (DISTINCT manager_id) "Number of Managers" FROM
employees;
8. Find the difference between the highest and lowest salaries. Label the column
DIFFERENCE.
a. SELECT MAX (salary) - MIN (salary) DIFFERENCE FROM employees;
[Show More]