Querying With Transact-SQL: Lab 7 - Using Table Expressions
Querying With Transact-SQL: Lab 7 - Using Table Expressions
Overview
In this lab, you will use views, temporary tables, variables, table-valued functions, derived tables, and
common table expressions to retrieve data from the AdventureWorksLT database.
Before starting this lab, you should view Module 7 – Using Table Expressions in the Course Querying
with Transact-SQL. Then, if you have not already done so, follow the instructions in the Getting Started
document for this course to set up the lab environment.
If you find some of the challenges difficult, don’t worry – you can find suggested solutions for all of the
challenges in the Lab Solution folder for this module.
Create a table variable and populate it with a list of distinct colors from the SalesLT.Product table. Then
use the table variable to filter a query that returns the product ID, name, and color from the
SalesLT.Product table so that only products with a color listed in the table variable are returned.
Tip: Review the documentation for the WITH common_table_expression syntax in the Transact-SQL
language reference.
Next Steps
Well done! You’ve completed the lab, and you’re ready to learn how to summarize data by specifying
grouping sets and pivoting data in Module 8 – Grouping Sets and Pivoting Data in the Course Querying
with Transact-SQL.