Select Data  «Prev  Next»

Using Transact-SQL Subqueries - Exercise

Creating and using subqueries in SQL-Server

Objective: Practice creating a subquery.

Exercise scoring

This exercise is worth a total of 20 points. You will receive up to 20 points for accurately creating the subquery as described in the instructions.

Exercise Instructions

  1. Consider the following table, named Division:
101North East
102South East
104North West
105South West

Now consider the following table, named Employee:

EmployeeID DivisionID PayGrade
1 101 A
2 103 A
3 102 B
4 101 B
5 101 C

Write a subquery that will select only the DivisionName from the Division table for all employees that have a PayGrade of B in the Employee table. Make sure that you use an IN clause and not join the two tables together.

Submitting the exercise

Type or paste your Transact-SQL statement into the text box below, then click Submit to submit them and view a results page.