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

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

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) ;