>>-select-clause-from-clause-+--------------+-------------------> '-where-clause-' >----+-----------------+--+---------------+-------------------->< '-group-by-clause-' '-having-clause-'
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 may be quite different from this description.)
The clauses of the subselect are processed in the following sequence:
.-ALL------. >>-SELECT----+----------+---------------------------------------> '-DISTINCT-' >-----+-*--------------------------------------------------+--->< | .-,---------------------------------------------. | | V | | '----+-expression--+--------------------------+-+--+-' | | .-AS-. | | | '-+----+--new-column-name--' | '-exposed-name.*---------------------------'
The SELECT clause specifies the columns of the final result table. The column values are produced by the application of the select list to R. The select list is the names or expressions specified in the SELECT clause, and R is the result of the previous operation of the subselect. For example, if the only clauses specified are SELECT, FROM, and WHERE, R is the result of that WHERE clause.
Two rows are duplicates of one another only if each value in the first is equal to the corresponding value of the second. For determining duplicates, two null values are considered equal.
The list of names is established when the program containing the SELECT clause is bound. Hence, * (the asterisk) does not identify any columns that have been added to a table after the statement containing the table reference has been bound.
The list of names is established when the statement containing the SELECT clause is bound. Therefore, * does not identify any columns that have been added to a table after the statement has been bound.
The number of columns in the result of SELECT is the same as the number of expressions in the operational form of the select list (that is, the list established when the statement is prepared) and cannot exceed 500.
For limitations on the select list, see Restrictions Using Varying-Length Character Strings.
Some of the results of applying the select list to R depend on whether or not GROUP BY or HAVING is used. The results are described in two separate lists: