Introduction

Completed

Microsoft SQL Server provides set operators for performing operations using the sets that result from two or more different queries. Set operators allow you to combine, compare, or operate on result sets.

In this module, you will learn how to use the set operators UNION and INTERSECT to compare rows between two input sets. You will also learn how to use forms of the APPLY operator to use the result of one query to collect the output of a second query, returning the output as a single result set.

When working with set operators, if you need the results to be sorted, add an ORDER BY statement to the final result. You should not use the ORDER BY statement with the input queries.

After completing this module, you’ll be able to:

  • Use the UNION operator.
  • Use the INTERSECT and EXCEPT operators.
  • Use the APPLY operator.