Subqueries in SQL Server 2016 are nested SELECT statements used to created more effective queries in T-SQL. This course will introduce subqueries and correlated subqueries, and cover the EXISTS predicate, a mechanism used in SQL Server 2016 to check whether any results will be returned from a specific query. This course is one of a series of courses that cover the objectives for 70-761: Querying Data with Transact-SQL exam.
Learning Objectives
Working with Subqueries
- start the course
- recognize when and where to use subqueries in SQL Server 2016
- describe the benefits of using scalar subqueries
- demonstrate how to write scalar subqueries in SQL Server 2016
- recognize how to write multi-valued subqueries in SQL Server 2016
Correlated Subqueries
- work with correlated subqueries in SQL Server 2016
- describe how to write correlated subqueries
- recognize how to write correlated subqueries with aliases
- describe how to write correlated subqueries with aliases
- describe how to write correlated subqueries in a HAVING clause
EXISTS Predicate
- describe how the EXISTS predicate evaluates data in SQL Server 2016
- describe how to write queries using EXISTS with subqueries
- demonstrate how to use EXISTS and NULLs in SQL Server 2016
- describe how to use EXISTS and INNER JOINS in SQL Server 2016
- demonstrate how to use NOT EXISTS with OUTER JOINs
Practice: Creating Subqueries in SQL Server 2016
- use subqueries in SQL Server 2016