The subselect is a component of the fullselect.
A subselect specifies a result table derived from the tables, views or nicknames 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 can 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 might or might not be executed.)
The authorization for a subselect is described in the Authorization section in "SQL queries".
- FROM clause
- WHERE clause
- GROUP BY clause
- HAVING clause
- SELECT clause
- ORDER BY clause
- OFFSET clause
- FETCH clause
- In the outermost fullselect of a view.
- In the outer fullselect of a materialized query table.
- Unless the subselect is enclosed in parenthesis.
The following example is valid:
SELECT * FROM T1 ORDER BY C1 UNION SELECT * FROM T2 ORDER BY C1
(SELECT * FROM T1 ORDER BY C1) UNION (SELECT * FROM T2 ORDER BY C1)