Show TOC Start of Content Area

This graphic is explained in the accompanying text Select List  Locate the document in its SAP Library structure

The select list is used to specify expressions and display names for the columns of the result table of a query specification.

Note

Although syntactically this clause is the first clause of a query specification, it is evaluated last.

 

Syntax

This graphic is explained in the accompanying text

<select list> ::= '*'
                | <derived column> ( ',' <derived column> )*.

<derived column> ::= <value expression>
                     ( ( AS )? <column alias>)?.

<display name> ::= the name of the column in the result set; see below

 

The <select list> can be applied to a grouped table (the result of GROUP BY or HAVING  clause), or an ungrouped table (the result of FROM or WHERE clause).

If the <select list> contains a <set function> and the table, to which it is applied, is not already grouped (that is, neither a GROUP BY clause nor a HAVING clause has been applied), the table is implicitly grouped. The result is a grouped table with just one group that has no grouping columns.

If the <select list> is applied to a grouped table, then the column references in the <select list> must either reference a grouping column, or must be specified inside a <set function>. The cardinality of the result table is the number of groups in the grouped table. If the <select list> contains a <set function>, all columns that are not aggregated must be listed in the GROUP BY clause.

If the <select list> is applied to an ungrouped table, the cardinality of the result table is the number of rows in the ungrouped table.

If the <select list> is '*', the result table is the table to which the <select list> is applied. For every column in the result set, the <display name> is the <column name> of the <column reference> underlying the result set column.

If the <select list> is not '*', the <display name> of the result set columns is determined as follows:

      If a <column alias> is specified, the <display name> is that <column alias>,

      else,

       if the <value expression> is a <column reference>, then the <display name> is the <column name> of the <column reference>.

       Otherwise, the <display name> is undefined.

The result of a <select list> is a table with the same degree as the <select list>. Each <value expression> is evaluated for every row respective group of the table and the result row consists of the sequence of these values.

Examples

This graphic is explained in the accompanying text

SELECT * FROM employees

SELECT *.  This query selects all columns from all rows of the table employees.

This graphic is explained in the accompanying text

SELECT employee_name AS name, salary FROM employees

Derived Column List.  This query selects the name and the salary for all employees.

More Information

Value expressions

GROUP BY Clause

HAVING Clause

End of Content Area