RIGHT OUTER JOIN in Teradata

A right outer join (or right join) closely resembles a left outer join, except with the treatment of the tables reversed. Every row from the "right" table (B) will appear in the joined table at least once. If no matching row from the "left" table (A) exists, NULL will appear in columns from A for those records that have no match in B.

A right outer join returns all the values from the right table and matched values from the left table (NULL in case of no matching join predicate). For example, this allows us to find each employee and his or her department, but still show departments that have no employees.

Consider the following two tables,
Employee table
LastNameDepartmentID
Rafferty31
Jones33
Steinberg33
Robert34
Smith34
JohnNULL


Department table
DepartmentIDDepartmentName
31Sales
33Engineering
34Clerical
35Marketing

SELECT *
FROM employee
RIGHT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

Employee.LastNameEmployee.DepartmentIDDepartment.DepartmentNameDepartment.DepartmentID
Smith34Clerical34
Jones33Engineering33
Robert34Clerical34
Steinberg33Engineering33
Rafferty31Sales31
NULLNULLMarketing35