SAP SELECT CLAUSE ABAP Statements
Get Example source ABAP code based on a different SAP table
• DISTINCT SELECT - select_clause
SELECT>, select_clause> Short Reference >
ABAP_SYNTAX
... $[DISTINCT$] select_list> ...>
ABAP Addition
... DISTINCT>
What does it do?
SELECT> clause of a query>. The SELECT > clause defines the structure of the result set of the SELECT > statement. It consists of a SELECT> list >, which defines the columns of the result set, and an optional addition DISTINCT>, which removes duplicative rows from the result set.
The SELECT> list select_list>> can indicate all columns of a data source using *> or it defines the individual columns of the result set using an SQL expression>. It defines the names of the columns in the result set, using optional or mandatory alias names.
Latest notes:
The SELECT> clause must either be listed as the first clause after the keyword SELECT>, or after the optional addition SINGLE>, or after the FROM> clause. After the FROM> clause, the SELECT> clause must be introduced using the addition FIELDS>>.
NON_V5_HINTS
A FROM> clause in front of the SELECT> clause supports tools such as the code completion in the ABAP Editor.
ABAP_HINT_END
ABAP_EXAMPLE_VX5
SELECT> clause after FIELDS>, whose SELECT> list specifies individual columns as well as aggregate expressions as arguments using SQL expressions.
ABEXA 00586
ABAP_EXAMPLE_END
ABAP Addition
What does it do?
The addition DISTINCT> removes rows that occur more than once in a multirow result set. Here, the entire row content is respected.
The addition DISTINCT> must not be used in the following cases:
If the addition SINGLE>> is used.
If a column specified in the SELECT> list select_list>> has the type STRING>, RAWSTRING>, LCHR>, LRAW>, or GEOM_EWKB>.
If DISTINCT> is used, the statement SELECT> bypasses table buffering>.
Latest notes:
For the addition DISTINCT>, it is not important which columns of the result set are key fields of the associated DDIC database tables, views, or CDS entities.
The comparison is based on the entire row content, which means that the number of rows in the result set depends on the SELECT> list>. If, for example, all key fields of a DDIC database table are specified directly as columns> in a SELECT>> list, there can be no rows that occur more than once. The other extreme is the case where a SELECT> list contains a single host variable> or a single literal. Here, all rows are deleted except one.
As a part of the SELECT> clause, the addition DISTINCT> has an effect before the additions UP TO> > and OFFSET>> are evaluated.
If DISTINCT> is specified, it should be noted that this requires the execution of sort operations in the database system, and the statement SELECT> therefore bypasses table buffering>.
NON_V5_HINTS
ABAP_HINT_END
ABAP_EXAMPLE_VX5
Output of all destinations to which Lufthansa flies from Frankfurt.
ABEXA 00587
ABAP_EXAMPLE_END
Return to menu