[Figure: Example of specifying UNION in query expression]
If UNION is used to join query specifications, a new table is derived corresponding to the columns in both query
specification results. The column sequence is from the left. Each query specification must be specified as follows:
· The number of columns in the results table must be the same as in the query specification.
· The data type for columns for each corresponding results table must be comparable.
For information about comparable data types, see Table "Comparable data types".
The column names in the table for the query expression results are the column names specified in the query
specification on the left. However, if the select column list in the query specification on the left is an operational
expression or set function, the columns in the results table do not have names.
Including duplicate rows in aggregate without modification
Specify ALL and UNION to derive a table from all rows from each query specification result without having duplicate
rows specified as one row. Figure: Example of specifying UNION ALL in query specification shows the kind of table
derived when ALL and UNION are specified.
Example 2:
In this example, the aggregate is obtained for all rows in columns COLA and COLC in table TBL1 and
columns COLZ and COLX in table TBL2 in Figure: Example of specifying UNION ALL in query
specification. Duplicate rows are also included.
68