
Description
The database table DEMO_SUMDIST_AGG is filled with aggregated data from the tables SCARR and SPFLI.
First, a standalone SELECT statement is used to read the aggregated data into an internal table and then the statement INSERT is used to write it to the database table. This requires two database reads and the transport of the data between the database server and application server.
The same SELECT statement is then used directly as a subquery in the INSERT statement. Only a single database read and no transport of data between the database server and application server is then required.
The result of both INSERT statements is the same. DEMO_SUMDIST_AGG is a global temporary table (GTT), which means that its content must be deleted before the results are produced (since this creates an implicit database commit).