[Figure: Example of performing an operation on different rows]
5.5 Obtaining the Aggregate for Rows from Multiple Table
s
The aggregate for rows contained in multiple tables can be obtained by joining two or more query specifications with
"UNION". Specify the tables to be processed and the conditions for fetching data in the query specifications. In
obtaining the aggregate, rows in which the column values are the same can be specified as one row. Also, the original
row count can be specified without modification.
Specifying duplicate rows as one row during aggregation
The result of using UNION to join query specifications is that the rows for each query specification result are collected
and a table is derived. In addition, duplicate rows are specified as one row. Duplicate rows are those rows in which the
column values are the same. Figure: Example of specifying UNION in query expression shows the kind of tables that
are derived from the result of using UNION to join query specifications.
Example 1
In this example, the aggregate is obtained for rows in columns COLA and COLC in table TBL1 and
columns COLZ and COLX in table TBL2 in Figure: Example of specifying UNION in query expression.
Tables TBL1 and TBL2 are contained in schema SCM.
67