[Figure: Example of specifying UNION ALL in query specification]
Aggregate sequence due to UNION
Query specifications joined by UNION are processed in sequence from the left. However, parentheses can be used to
specify a different evaluation sequence. A query expression enclosed in parentheses is processed before other query
expressions. The following is an example of using parentheses in a query specification joined by UNION:
Example 3:
In this example, an aggregate is obtained for tables TBL1, TBL2, TBL3, and TBL4. First, duplicate rows
in tables TBL1 and TBL2 are removed and the aggregate is obtained [1]. Next, duplicate rows in tables
TBL3 and TBL4 are removed and the aggregate is obtained [2]. Finally, all rows, including the
duplicated rows, in these results are included and the aggregate is obtained [3].
69