SELECT List (SELECT Statement)

The SELECT list appears as the first clause in a SELECT statement, but it is not the first logical step. The other clauses produce a set of rows, the "source rows," from which the output is derived.

The SELECT list determines which columns from these rows are output. It may directly output these columns, or it may use them in aggregate functions or value expressions. Value expressions can be NUMERIC, STRING, DATETIME, or INTERVAL. They may include aggregate functions and subqueries.

If DISTINCT is specified, the rows are compared and if any duplicate rows are found, only one copy appears in the output. The SELECT clause may contain any of the following:

Aggregate functions Functions that extract single values from groups of column values, for example, SUM or COUNT
An asterisk (*) Causes all the columns of all tables listed in the FROM clause to be output in the order in which they appear in the FROM clause
A qualifier Where the "qualifier" is the table or correlation name referenced in the FROM clause. All columns of that (possibly derived) table are output, excluding common columns of joined tables
A value expression Normally is (or includes) a column name from one of the tables identified in the FROM clause. Either the column's value is directly output or it becomes part of some expression, such as
AMOUNT * 3
A specified column name     If the output columns are directly taken from only one column referenced in the FROM clause, it inherits the name of that column by default. You can override this name by using the AS clause. The names of columns not directly taken from input columns are implementation-dependent. You are not required to name any output columns by the SELECT clause, but may be required to by the context of the way the output columns are to be used (for example, in a view). The keyword AS is not required because it is implied

If aggregate functions and value expressions are mixed, all the value expressions must be specified in a GROUP BY clause.