Previous Topic: Using a Subquery with INNext Topic: Using an Aggregate Function in a Nested SELECT Statement


Exercise 7-1

Now You Try It

The Human Resources department needs to find out which departments have employees with more than 80 hours of vacation remaining for fiscal year 1999 so that the department head can be notified.

Enter a SELECT statement using a subquery to identify the IDs of those departments.

What tables are involved?

You need to access the BENEFITS table first to find out about remaining vacation hours. Then access the EMPLOYEE table to find the department ID.

You can use DISTINCT to eliminate duplicates.

The result looks like this:

 DEPT_ID  -------     4600     6200  2 rows processed

If your results do not match what you see above, check Review Answers for Chapter 7 for the correct SQL syntax. Remember that result tables may be shortened in this guide.