RelationalDBDesign
SiteMap
Business Rules
Cursors Views
Database Creation
SQL Monitoring
Database Web Apps
Data Manipulation
Access Features
Tables Queries
Select Data
«Prev
Next»
Queries Cursors Views
SQL-Query Basics
Executing Queries
Batch Queries
System Catalogs
Writing Logic Queries
Dynamic SQL Statements
SQL Server Basics
Selecting Data
Data Overview
Retrieving Data Multiple Tables
Multiple Table Retrieval
Alternate Queries Aliases
Construct Union Queries
Additional Keywords Queries
Define Aggregate Queries
Aggregated Data Queries
Describe Write Subqueries
Using Subqueries - Exercise
Selecting Data Conclusion
Advanced Queries
Inserting Transact SQL Data
Updating Transact-SQL Data
Deleting Data
SQL Statement Punctuation
Insert Values from other Table
Update Values from other Table
Different Datatypes
Subquery Statements
Indexing Query Strategies
Full Text Searching
Full Text Searching
Full Text Searching Components
Defining Full Text Indexes
Implement Full Text Search
Full Text Searching
SQLConfiguration
Queries Cursors Views
SQL Query Basics
Selecting Data
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
Consider the following table, named Division:
DivisionID
DivisionName
101
North East
102
South East
103
Central
104
North West
105
South 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.
Submit