Joining a table to itself is known as a self-join. Self-joins correlate the data in a single table. For example, assume you have an Employee table that contains columns for EmployeeID and ManagerID. A self-join would find all the matching pairs of EmployeeID and ManagerID.
SQL does not allow you to do a true self-join. This means that you cannot join the columns in a single table. Instead, you must create a copy of the table and join it with the original. Since table names in the query must be unique, you must also create an alias for the copy.
To create a table self-join:
Select a table on the Query Builder - Tables page and add it to your query (see Selecting Tables).
Add the table again by highlighting the table under Available Tables and clicking .
When you add the table a second time, the Define Table Alias dialog box is displayed (see Defining Table Aliases).
In the Define Table Alias dialog box, enter an alias for the table and click OK.
Aliases cannot duplicate original table names and cannot match any other table names in the query or under the schema. SQR Production Reporting Studio displays a warning if a table name duplicates an existing table name.
Click Next to advance to the Query Builder - Join Tables page (see Joining Tables).
Create a join between the table and its alias by dragging a column from one table to another.