ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Read Accesses →  SELECT →  SELECT - WHERE →  WHERE - sql_cond → 

sql_cond - subquery Syntax Diagram

Short Reference

Syntax

... ( SELECT result
      FROM source
            [WHERE sql_cond]
             [GROUP BY group] [HAVING group_cond] ) ...

Effect

A subquery is a SELECT statement in parenthesis in which all additions except SINGLE, INTO, and ORDER BY can be used. A subquery with a single-column resulting set, in other words, the specification of the columns in the expression result of the subquery is limited to one column or to an aggregate expression, is known as a scalar subquery.

A subquery can be used within the following relational expressions sql_cond of the WHERE conditions for a subquery:

Subqueries can be nested by using subqueries in the WHERE conditions of a subquery. In nested subqueries, the columns specified in the WHERE conditions are searched inside out, though the columns of inner subqueries conceal columns with the same name in outer subqueries.

A subquery that uses columns from the surrounding SELECT statement in its WHERE condition, is known as a correlated subquery. It must be possible to assign the column uniquely to a database table or view in the surrounding SELECT statement. A correlated subquery is evaluated for each individual line of the resulting set in the surrounding SELECT statement.

A maximum of 10 SELECT statements are permitted within one ABAP statement, in other words the SELECT itself and a maximum of 9 other subqueries. This restriction is independent of whether the subqueries are nested or occur in different relational expressions of the WHERE condition.

Notes




Continue
sql_cond - ALL, ANY, SOMEsubquery
sql_cond - EXISTS subquery
sql_cond - IN subquery
Subqueries