Ansicht
Dokumentation

ABENSELECT_UNION_ABEXA - SELECT UNION ABEXA

ABENSELECT_UNION_ABEXA - SELECT UNION ABEXA

ROGBILLS - Synchronize billing plans   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

SELECT, Union of Multiple Tables

This example demonstrates how a union is created across multiple tables.

Source Code

Execute

Description

Four columns of the same type from result sets from three database tables DEMO_JOIN1, DEMO_JOIN2 and DEMO_JOIN3 are combined to different SELECT statements using UNION. The DDIC database tables are filled in the static constructor.

  • The first statement shows the default behavior with addition DISTINCT. No rows are inserted from DDIC database table DEMO_JOIN2 and one row is not inserted from DDIC database table DEMO_JOIN3 because these rows already exist.
  • The second statement shows the behavior with addition ALL. All the rows from the three result sets are combined into one result set without removing any rows.
  • The third statement contains addition ALL in the first UNION and contains DISTINCT in the second union. The addition DISTINCT deletes all duplicate rows, including the rows created using addition ALL. Therefore, the result is the same as in the first statement.
  • The fourth statement is the same as the third, except that parentheses have been inserted here. First, the parentheses are evaluated. The addition DISTINCT only works in the parentheses and removes the first row from DEMO_JOIN3. Afterwards the result set of the parentheses is completely inserted into the result set of DEMO_JOIN1.
  • The fifth statement contains addition DISTINCT in the first UNION and contains ALL in the second union. In the first union, no rows are taken from DEMO_JOIN2 because all the rows already exist. Next, all the rows are inserted from DEMO_JOIN3.
  • The sixth statement is the same as the fifth, except that parentheses have been inserted here. Once the parentheses have been evaluated, their corresponding result set contains all rows from DEMO_JOIN2 and DEMO_JOIN3. In the union with rows from DEMO_JOIN1, all duplicate rows are removed using DISTINCT, which means that the result is the same as with the first statement.





CPI1466 during Backup   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 2483 Date: 20240424 Time: 232258     sap01-206 ( 56 ms )