select-clause

The SELECT clause specifies the columns of the final result table.

Read syntax diagramSkip visual syntax diagramSELECTALLDISTINCT*,expressionAScolumn-nametable-name.*view-name.*correlation-name.*

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.

ALL
Selects all rows of the final result table and does not eliminate duplicates. This is the default.
DISTINCT
Eliminates all but one of each set of duplicate rows of the final result table. Two rows are duplicates of one another only if each value in the first row is equal to the corresponding value in the second row. (For determining duplicate rows, two null values are considered equal.) The collating sequence is also used for determining distinct values.

DISTINCT is not allowed if the select-list contains a DATALINK or XML column, or an expression that returns a value that is the XML data type.

Start of changeColumn access controls do not affect the operation of SELECT DISTINCT. The elimination of duplicated rows is based on the original column values, not the masked values. However, after the application of column masks, the masked values in the final result table might not reflect the uniqueness that is enforced by SELECT DISTINCT.End of change

Start of changeIf a column mask is applied to a column that directly or indirectly derives the result of SELECT DISTINCT, SELECT DISTINCT can return a result that is not deterministic. The following conditions are a few examples of when a result that is not deterministic might be returned:Start of change
  • The definition of the column mask references other columns of the table to which the column mask is applied.
  • The column is referenced in the argument of a built-in scalar function, such as COALESCE, IFNULL, NULLIF, MAX, MIN, LOCATE, etc.
  • The column is referenced in the argument of an aggregate function.
  • The column is embedded in an expression and the expression contains a function that is not deterministic or has an external action.
End of change End of change