Specifies a projection list for a query.
SELECT { expression[AS column]}[,...]
expression | An expression that evaluates to a value of the same data type as the corresponding destination column. |
column | the name of a column in a query destination. |
The expressions within each select list item can contain literals, column names from sources referenced in the FROM clause, operators, scalar functions, and parenthesis. A wild card (*) selects all the columns from underlying sources referenced in the FROM clause. The AS column reference must map to a column name in the destination.
All the items in the projection must use the AS extension to map the items to the destination columns, or none of them should, in which case the assignment is performed left to right. Under some circumstances, a schema can be automatically generated for the destination, based on a query. For expressions, provide a column with the AS extension.
The SELECT clause inside a query specifies a select-list of one or more items. Rows from the datasources listed in the FROM clause are passed to the SELECT clause after being filtered by the WHERE clause, if specified. The results of the expressions in the list are processed by other clauses (if any). The query usually uses the processed select-list results as its input.
These rules apply to the select-list:
The expression within each select-list item can contain literals, column names from one of the datasources listed in the FROM clause, operators, scalar and miscellaneous functions, and parentheses. A query select-list expression can also include aggregate functions.
Alternately, you can use the "select all" (wildcard) character (*) to specify expressions. This is equivalent to listing all column values from all datasources listed in the statement's FROM clause, from left to right, or to using data-source.*, which is equivalent to a list of all column values from the specified data source (where data-source is the name or alias of one of the data sources listed in the FROM clause).
These rules apply to all expressions that do not include the wildcard character:
Each list item can specify an AS output column reference subclause indicating the column within the destination, to which the select-list item should be published. The AS subclause must be used either for all or for none of the items in the select-list.