Example: FROM Clause Left Outer Join - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The following example shows a left outer join. See Outer Joins.

The skills table contains skill numbers and associated names:

skill_no skill_name
1 baker
2 doctor
3 farmer
4 lawyer
5 mason
6 tailor

The emp table contains employee numbers and skills numbers:

emp_no skill_no
6123 1
6234 1
6392 3
7281 5
7362 4
6169 1

You can use this query to determine which skill areas do not have assigned employees:

SELECT skills.skill_name, emp.emp_no
FROM skills LEFT OUTER JOIN emp ON skills.skill_no=emp.skill_no;

The following result is returned. Nulls are displayed as a QUESTION MARK (?) character, which is how BTEQ reports nulls. For more information about BTEQ, see Basic Teradata® Query Reference, B035-2414.

skill_name emp_no
baker 6123
baker 6234
baker 6169
doctor ?
farmer 6392
lawyer 7362
mason 7281
tailor ?

To include all skills in the result, must specify an OUTER JOIN. An implicit join that uses only the simple FROM clause does not return rows for nulls (that is, when there are no corresponding employees) and does not list doctor or tailor in the preceding result.

…
FROM employee, skills
…