Example: Searching for NULL and NOT-NULL in the Same Statement

Teradata Vantage™ SQL Functions, Expressions, and Predicates

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

If you are searching for values that are NULL and non-NULL in the same statement, the search condition for the NULLs must appear separately.

For example, to select the names of all employees without the job title of “Manager” or “Vice Pres”, plus the names of all employees with a null in the JobTitle column, you must enter the statement as follows:

   SELECT Name, JobTitle 
   FROM Employee 
   WHERE (JobTitle NOT IN ('Manager' OR 'Vice Pres')) 
   OR (JobTitle IS NULL) ;