SAP SELECT GROUPING SETS ABEXA



Get Example source ABAP code based on a different SAP table
  



SELECT, Grouping Sets
This example demonstrates the GROUP BY addition GROUPING SETS of the statement SELECT.

ABAP_SOURCE_CODE
DEMO CL_DEMO_SELECT_GROUPING_SETS

ABAP_DESCRIPTION
For Lufthansa flights, this example calculates the sum of the maximum available seats depending on the plane type (column planetype) and the connection (column connid). Two grouping sets are defined, which contain either the plane type or the connection.
The example shows that SELECT statements that use UNION ALL or GROUPING SETS are equivalent. The first query defines the grouping sets ( carrid, planetype ) and ( carrid, connid ) with a GROUP BY clause. The second query, on the other hand, specifies the same grouping sets using two GROUP BY clauses and merges them using UNION ALL.