⟩ What Is a Subquery in a SELECT Query Statement in MS SQL Server?
A subquery is a SELECT statement used as part of the selection criteria of the main SELECT statement. The subquery specified in the WHERE clause will be evaluated repeated on each row of the selection base table. The output of the subquery will be used in the final evaluation of the criteria. Usually, subqueries are used in the following Boolean operations:
* "expression IN (subquery)" - True if the expression matches one of the returned values from the subquery.
* "expression NOT IN (subquery)" - True if the expression does not match any of the returned values from the subquery.
* "EXISTS (subquery)" - True if the subquery returns one or more rows.
* "NOT EXISTS (subquery)" - True if the subquery returns no rows.