The SELECT
Columns List
The columns list contains one or more comma-separated value expressions.Each expression provides a value for one output column.Alternatively, *
(“star” or “all”) can be used to stand for all the columns of all relations in the FROM
clause.
SELECT [...] [{ ALL | DISTINCT }] <select-list> [...] FROM ... <select_list> ::= * | <select-sublist> [, <select-sublist> ...] <select-sublist> ::= table-alias.* | <value-expression> [[AS] column-alias] <value-expression> ::= [table-alias.]col_name | [table-alias.]selectable_SP_outparm | <literal> | <context-variable> | <function-call> | <single-value-subselect> | <CASE-construct> | any other expression returning a single value of a Firebird data type or NULL <function-call> ::= <normal-function> | <aggregate-function> | <window-function> <normal-function> ::= !! See Built-in Scalar Functions !! <aggregate-function> ::= !! See Aggregate Functions !! <window-function> ::= !! See Window Functions !!
Argument | Description |
---|---|
table-alias |
Name of relation (view, stored procedure, derived table), or its alias |
col_name |
Name of a table or view column, or its alias |
selectable_SP_outparm |
Declared name of an output parameter of a selectable stored procedure |
literal |
A literal |
context-variable |
Context variable |
function-call |
Scalar, aggregate, or window function expression |
single-value-subselect |
A subquery returning one scalar value (singleton) |
CASE-construct |
CASE construct setting conditions for a return value |
It is always valid to qualify a column name (or “*
”) with the name or alias of the table, view or selectable SP to which it belongs, followed by a dot (‘.
’).For example, relationname.columnname
, relationname.*
, alias.columnname
, alias.*
.Qualifying is required if the column name occurs in more than one relation taking part in a join.Qualifying “*
” is required if it is not the only item in the column list.
Important
|
Aliases hide the original relation name: once a table, view or procedure has been aliased, only the alias can be used as its qualifier throughout the query.The relation name itself becomes unavailable. |
The column list may optionally be preceded by one of the keywords DISTINCT
or ALL
:
-
DISTINCT
filters out any duplicate rows.That is, if two or more rows have the same values in every corresponding column, only one of them is included in the result set -
ALL
is the default: it returns all rows, including duplicates.ALL
is rarely used;it is allowed for compliance with the SQL standard.
A COLLATE
clause of a value-expression will not change the appearance of the column as such.However, if the specified collation changes the case or accent sensitivity of the column, it may influence:
-
The ordering, if an
ORDER BY
clause is also present, and it involves that column -
Grouping, if the column is part of a
GROUP BY
clause -
The rows retrieved (and hence the total number of rows in the result set), if
DISTINCT
is used