subselect

The subselect is a component of the fullselect.

Read syntax diagramSkip visual syntax diagramselect-clausefrom-clausewhere-clausehierarchical-query-clause group-by-clausehaving-clause order-by-clause offset-clause fetch-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.)

Start of changeWhen a subselect directly or indirectly references a table for which row or column access control is enforced, the rules that are defined in the row permissions or column masks affect how the rows in the result table are derived. Typically those rules are based on the authorization ID of the process.End of change

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. Start of changeOFFSET clauseEnd of change
  9. FETCH clause