SAP SQL EXPR WITH GROUP BY ABEXA



Get Example source ABAP code based on a different SAP table
  



SELECT, GROUP BY for SQL Expressions
This example demonstrates non elementary SQL expressions combined with the addition GROUP BY.

ABAP_SOURCE_CODE
DEMO CL_DEMO_SQL_EXPR_WITH_GROUP_BY

ABAP_DESCRIPTION
An arithmetic expression after SELECT adds the values of the columns NUM1 and NUM2 and passes the total to the result set as SUM. The aggregate function count( * ) counts the rows of a group. NUM1 and NUM2 must be specified for the grouping after GROUP BY.
The first SELECT statement specifies NUM1 and NUM2 as individual columns after GROUP BY. The rows are grouped by these columns. Distinct values in these columns produce separate groups, even if the total is the same.
The second SELECT statement specifies NUM1 and NUM2 in an SQL expression after GROUP BY. The rows are grouped by the result of the expression.