Example: Searching a Table That Might Contain Nulls - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-30
dita:mapPath
tpt1555966086716.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantageā„¢

You must be careful when searching a table that might contain nulls. For example, if the EdLev column contains nulls and you submit the following query, the result contains only the names of employees with an education level of less than 16 years.

   SELECT Name, EdLev 
   FROM Employee 
   WHERE (EdLev < 16) ;

To ensure that the result of a statement contains nulls, you must structure it as follows.

   SELECT Name, EdLev 
   FROM Employee 
   WHERE (EdLev < 16) 
   OR (EdLev IS NULL) ;