select-clause

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

Read syntax diagramSkip visual syntax diagram
           .-ALL------.   
>>-SELECT--+----------+----------------------------------------->
           '-DISTINCT-'   

>--+-*-------------------------------------------+-------------><
   | .-,---------------------------------------. |   
   | V                                         | |   
   '---+-expression--+---------------------+-+-+-'   
       |             | .-AS-.              | |       
       |             '-+----+--column-name-' |       
       +-table-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.

Start of changeDISTINCT 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.End of change