You use join transformations to join result set columns from different
queries and tables.
About this task
Join transformations allow you to join columns from different queries or tables from either
the same or different data sources to one result set. You specify any number of join conditions, and
specify inner, left, right, or full joins. You can use Collate Option for
case sensitive or case insensitive comparison of data on the Join Columns.
The Collate option gets activated only when the Join
Columns entry is of the type string, var char, or text. To configure a join transformation in the analytical query
structure:
Procedure
- In the Analytical query structure, select
a join transformation node.
In the Item editor pane, you can view the items of the join transformation. The columns from the source data set in the upper node are displayed in the Left Columns list.
The columns from the source data set in the lower node are displayed in the Right Columns list.
- Optional: If the selected join transformation is not populated yet, add queries or tables into
<none> nodes. For more information, see Populating analytical query transformations.
- On the toolbar in the Item editor, select the type of join.
- Inner join to include in the query results
only those rows with matching values in both tables.
- Left outer join to include in the query
results all the rows in the left table and only the rows from the
right table that match with rows from the left table.
- Right outer join to include in the query
results all the rows in the right table and only the rows from the
left table that match with rows from the right table.
- Full outer join to include in the query
results all rows from both tables.
- Specify the query result columns that you want to join
together.
- Select a column from the Left Columns list.
- Select a column from the Right Columns list.
- From the Join Columns list, select the check box next to the join condition.
The new join condition
is added to the Join Columns list and the Condition(s) Added check box is selected.
- Repeat this procedure for each join condition that you
want to add. For each new join condition, you can only use columns that were not previously selected.
- To clear the Join Columns list, deselect the Condition(s) Added check box.
-
If you are populating a join transformation structure with objects that contain similar names,
you can try to automatically create appropriate join conditions by clicking
Automatch.
If there are any possible automatches, they are displayed in the
Join
Columns list.
Note: Clicking Automatch will erase any join
conditions that you previously set.
- Optional: You can configure the join condition to be applied in case
sensitive or case insensitive manner by clicking on the Collate Option
button. Specify Collate Option for each join column by selecting case
sensitive or case insensitive option from the drop-down provided.
Note: Collate Option button is enabled when at least one of the join column
is of the character data type.
- To add a column to the Result Columns list, select the check box next to this column.
- To move a column up or down the Result Columns list, select the column
and click Move Column Up or Move Column Down buttons above the Result Columns list.
- To add all of the Left Columns or Right Columns to the Result Columns list, select the Include
All Columns check box above the respective column list.
- To remove all of the Left Columns or Right Columns from the Result Columns, deselect the Include
All Columns check box above the respective column list.
- Optional: To add another transformation to the current analytical query structure, follow the procedure described in Building analytical query structures.
Results
Whether it is the only transformation in an analytical query or one of many nodes in a
complex structure, a join transformation can be run on a database to accelerate the execution of the
entire analytical query. In the Output view, you can see that SQL Join is
applied for such transformations. Generally, join transformations are run on databases if they
contain queries with simple SQL statements using only the SELECT operator and retrieving data from
one database. Db2 database queries can also apply SQL statements that involve join conditions, sort
conditions, row conditions, calculated columns, simple filtering, groups, and categorizations. Join
transformations with MS SQL database queries are always run locally.Note: When performing join
transformations, you must ensure that the data in the columns, on which join is performed, are in
the same format. That is:
- columns with textual data should be in the same case to be considered unique. For example, "IBM"
and "ibm" are considered as distinct values.
- columns with numerical data should have the same precision and scale to be considered unique.
For example, "12.010" and "0000012.01" are considered as distinct values.
- columns with date data should be in the same format to be considered unique. For example,
"12/02/1980" and "12/02/80" are considered as distinct values.
- columns with currency data should be in the same format to be considered unique. For example,
"$100" and "$100.00" are considered as distinct values.
To ensure that the join transformation is applied correctly, you can choose to use the database
or QMF format functions to format the data.