5.1.2 Union

By default, the union of two tables contains all of the unique rows from the two tables. The first table you select is the table whose distinct rows will appear first in the result. By default, no duplicate rows are retained in the union table. For information on how to preserve duplicate rows in the union table, see Changing the Concatenation Type.

For information on how to create a union table, see Creating a Concatenated Table or the example below.

Example: Union  >>

Say you have two queries: One returning a list of customers who have purchased more than 100 pieces of 'Wireless Mouse' and the other returning a list of customers who have purchased more than 100 pieces of 'Fast Go Game'. If you desire to have both these pieces of information provided as one entity, you can write another SQL query that is a union of the two above mentioned queries. However, the necessity of writing a new query can be eliminated by performing the union of the two tables, each bound to one of the two queries.

Follow the steps below to concatenate two tables in order to see the contact information of all customers who have purchased more than 100 pieces of either 'Wireless Mouse' or 'Fast Go Game' in one table.

1. Create a new Worksheet by clicking on the 'New Worksheet' button.

2. Expand the 'Data Source' node, the 'Orders' node, and the 'DWS' node.

3. Drag the 'Fast Go Game' node from the tree to an empty cell in the Worksheet. A new table named 'Fast Go Game1' is created.

4. Drag the 'Wireless Mouse' node from the tree to an empty cell in the Worksheet. A new table named 'Wireless Mouse1' is created.

 

5. Ctrl-click the table title bars to select both tables.

6. Click on the 'Concatenate Table' button in the toolbar, and select 'Union'. A new table, 'Query1', is created. Notice that the title row includes the names of the tables participating in the concatenation and the type of concatenation (a union symbol in this case).

 

7. Preview the table 'Query1' by right-clicking on its title row and selecting 'Preview' from the context menu. The information for all customers who purchased more than 100 pieces of either 'Wireless Mouse' or 'Fast Go Game' is included in the table.

 

<< 5.1.1 Creating a Concatenated Table © 1996-2013 InetSoft Technology Corporation (v11.5) 5.1.3 Intersect >>