RelationalDBDesign
SiteMap
Business Rules
Cursors Views
Database Creation
SQL Monitoring
Database Web Apps
Data Manipulation
Access Features
Tables Queries
CRUD Statements
«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
Create a DELETE Statement using a Subquery - Exercise
Create a DELETE statement using a subquery
Objective:
Practice creating a DELETE statement using a subquery.
Exercise scoring
This exercise is worth a total of 5 points. You will receive up to 5 points for accurately creating the DELETE statement as described in the instructions.
Instructions
To test your understanding of the relationship between subqueries and joins, use the same instructions as the prior exercise, but construct a subquery instead of selecting values from another table. To review the instructions, use the course project as an example. Remember the Timesheets table looks like this:
EmployeeID
ClientID
TaskID
WeekEndingDate
Hours
1
17
101
6/1/99
30
1
17
102
6/8/99
50
2
3
101
6/15/99
40
3
32
103
6/1/99
45
3
32
103
6/8/99
35
The Tasks table looks like this:
TaskID
Description
Chargeable
101
Vacation
0
102
General
1
103
Programming
1
The task is to delete all employees from the Timesheets table for tasks that are not chargeable, as listed in the Tasks table. Construct a
DELETE
statement that uses a subquery from the Tasks table to retrieve the values to be deleted. Do not use a join.
Hint: You need to use an
IN
statement in the
WHERE
clause.
Submitting the exercise
Type or paste your Transact-SQL statement into the text box below, then click
Submit
to submit the answer and view a results page.