SAP SQL EXPR AGGR IN EXPR ABEXA
Get Example source ABAP code based on a different SAP table
ABAP_SQLEXP - Aggregate Expressions in SQL Expressions This example demonstrates
aggregate expressions as an argument of SQL expressions.
ABAP_SOURCE_CODE
DEMO CL_DEMO_AGGREGATES_IN_SQL_EXPR
ABAP_DESCRIPTION
The DDIC database table DEMO_EXPRESSIONS is filled with random values in the static constructor.
The first SELECT statement reads the filled columns individually. Here, the total and the product of the numeric columns NUM1 and NUM2 are calculated using arithmetic statements in the SELECT list.
The second SELECT statement performs a grouping by the columns CHAR1 and CHAR2. For each group, aggregated values whose arguments are aggregate expressions are determined using arithmetic expressions.
The third SELECT statement performs the same grouping as the second SELECT statement, but restricts the selected groups using a HAVING clause in which a condition is set on an arithmetic expression that has aggregate expressions as arguments.
See also the executable example for using SQL expression in aggregate expressions. Here, the roles of the expressions are switched, and different results are produced.