Explore BrainMass
Share

# SQL statements and query

(3.7) Write a SQL query that uses UNION of the two tables. Be creative.

Using the updated database, write the following queries using the SQL GROUP BY statement and appropriate aggregate statements (when needed):

(3.8) Write a SQL query that displays the average salary / hourly wage grouped by job_title.
(3.9) Write a SQL query that displays the number of people in each EE0-1 Classification and the average salary / hourly wage for each classification.
(3.10) Group employees by EEO classification: Select the employees' last names and group them by EEO-1 Classification
(3.11) Group employees by salary within their EEO classification: Select the employees' last names and group them by salary within their EEO-1 Classification.
(3.12) Select the employees' last names and group them by salary within job titles that are grouped into exempt and non-exempt.

Using the database and tables from Week Three, write queries to the specifications listed below.
(Note: Verify that the updates in the next three statements (4.1 - 4.3) are completed correctly by displaying the relevant columns before and after the updates run.)

(4.1) Choose an EEO-1 Classification: Increase all employees' salaries that have: the selected EEO-1 classification by 10%.
(4.2) Increase all employees' salaries by 5%.
(4.3) Choose an employee from the employee table; delete this employee.

Using the database and tables from Week Three, write SQL statements to:
(4.4) How many people are salaried and how many are hourly?
(4.5) Calculate the minimum salary for all salaried employees.
(4.6) Calculate the minimum hourly rate for all hourly employees.
(4.7) Calculate the average wage (salaried or hourly) for each EEO-1 Classification.
(4.8) Calculate the maximum salary for exempt employees and the maximum salary for non-exempt employees.
(4.9) Calculate the minimum salary for exempt employees and the maximum salary for non-exempt employees.

#### Solution Preview

3.7
SELECT Job_title, Wage FROM Employee
UNION ALL
SELECT Job_title, Exempt_Non_Exempt_Status FROM Job_title

3.8
SELECT Job_title, AVG(Wage)
FROM Employee
WHERE Wage BETWEEN 1.00 AND 25.00
GROUP BY Job_title

3.9
SELECT EEO_1_Classification, AVG(Wage), COUNT(Emp_id) as number_of_people
FROM Employee, Job_title
WHERE Employee.Job_title=Job_title.Job_title
GROUP BY EEO_1_Classification

3.10
SELECT Last_name, EEO_1_Classification
FROM Employee, Job_title
WHERE Employee.Job_title=Job_title.Job_title
ORDER BY EEO_1_Classification ...

#### Solution Summary

SQL statements and query are analyzed. The solution updates a database.

\$2.19