Appending Queries

When you need to view and merge multiple queries in a combined results set, there are four query operators that allow you to merge two or more separate queries. For example, you may need to merge the results of amount from sales by item, plus units from state sales by state. The operators and their functions are:

Query OperatorDescription
Union iconAll distinct rows selected by either query are retrieved. No duplicate rows are retrieved.
Union All iconAll rows selected by either query, including duplicate rows, are retrieved.
Intersection iconAll distinct rows selected by both queries are retrieved.
Except iconAll distinct rows selected by the first query but not the second query, are retrieved. (Oracle database servers refer to the Except operator as “Minus.”)

To specify an evaluation order, you can click Image shows Parentheses icon. to add parentheses to an expression which includes two queries or more. The default evaluation order is left to right.

Note:

If your database supports the Intersection and Except operators, but they are not available in the Operator drop-down list, check the Allow SQL-92 Advanced Set Operations connection preference.

The rules governing the use of these operators are:

  To append a query:

  1. Verify data types and associated column(s).

    This ensures that you know how to merge data in the second query.

  2. Build the Request line.

    Add server and local filters, data functions, and computations to the query as needed.

  3. Select Query, then Append Query.

    An Operator drop-down list and a second query tab is added below the Request, Filter, and Sort lines. The drop-down list shows whether the queries are linked by way of a union, a union all, an intersection, or an except.

  4. Build the second query.

  5. To merge multiple queries, select the operator to use from the Operator drop‑down list.

  6. Click Process.

    You can have Interactive Reporting generate automatically the join path required by the context of the query by using the automatic join path feature. This feature eliminates the need for you to predefine any join paths, because Interactive Reporting determines the paths. When multiple paths are available, you are prompted for which one to use.