Mentor SAP

Sub Queries Overview

In addition to UNION and JOIN, sub-queries or nested queries also provide the option of reading from multiple tables and views.

 

Nested queries contain what is called a “Sub Query”.

 

A subquery can be used to achieve the following:

 

There are different types of subqueries:

 

 

Uncorrelated Sub Queries

 

 

 

 

 

 

Correlated Sub Queries

 

 

 

 

 

 

Using nested queries, you can also perform the following:

 

Extended Sub Queries:

  1. You can use functions in a subquery
  2. You can use multiple columns in the subquery
  3. The Where clause of a subquery can contain another subquery.
  4. You can combine join and subqueries
  5. A subquery is usually part of the WHERE clause.
  6. A subquery is usually part of the WHERE clause., but you can also use a subquery in other clauses.