subselect

The subselect is a component of the fullselect.

Read syntax diagramSkip visual syntax diagram
>>-select-clause--from-clause--+--------------+----------------->
                               '-where-clause-'   

>--+---------------------------+--+-----------------+----------->
   '-hierarchical-query-clause-'  '-group-by-clause-'   

>--+---------------+--+-----------------+--+--------------------+-><
   '-having-clause-'  '-order-by-clause-'  '-fetch-first-clause-'   

A subselect specifies a result table derived from the tables or views identified in the FROM clause. The derivation can be described as a sequence of operations in which the result of each operation is input for the next. (This is only a way of describing the subselect. The method used to perform the derivation may be quite different from this description. If portions of the subselect do not actually need to be executed for the correct result to be obtained, they may or may not be executed.)

A scalar-subselect is a subselect, enclosed in parentheses, that returns a single result row and a single result column. If the result of the subselect is no rows, then the null value is returned. An error is returned if there is more than one row in the result.

The sequence of the (hypothetical) operations is:

  1. FROM clause
  2. Start of changehierarchical-query clauseEnd of change
  3. WHERE clause
  4. GROUP BY clause
  5. HAVING clause
  6. SELECT clause
  7. ORDER BY clause
  8. FETCH FIRST clause