Homework 1
CS122, Fall 2011
Due: Monday, October 31
Please put your queries in an SQL script file hw1.sql and upload
it to CSNS.
Note that file
uploading will be disabled automatically after 11:59PM
of the due date, so please turn in your work on time. Late submission will not be accepted.
[SQL] (27pt) Complete the following queries using the Human Resource Database.
For all the queries that ask for "names of the employees", the results
should have the employee names in one column in the form of "last
name, first name".
- List the names of the employees whose annual salary is
above $50,000.
- List the names of the employees who are managers, i.e.
their job
title has the word "Manager" in it.
- List the names of the employees who are not department
managers but earn more than $100,000 per year.
- List the average employee salary in each department. The
results
should include department name and average salary, and ordered by
average salary in descending order.
- List the average employee salary in each region. The
results
should include region name and average salary, and ordered by average
salary in descending order. For regions with no employees, display -1 as the
average salary.
- List the names of the employees who were hired in the last four years.
- List the names of the top 5 employees ranked by years of
service. "Years of service" can be calculated as current year minus the
year when the employee was hired.
- Find the phone number of John Russell's manager.
- Find the the names of the employees who have worked for more
than
one department.