Example: Using IN/NOT IN with a List of Literals - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantage™

This example shows the behavior of IN/NOT IN with a list of literals.

Consider the following table definition and contents:

   CREATE TABLE t (x INTEGER);
   INSERT t (1);
   INSERT t (2);
   INSERT t (3);
   INSERT t (4);
   INSERT t (5);
IF you use this query … THEN the result is …
SELECT * FROM t WHERE x IN (1,2) 1, 2
SELECT * FROM t WHERE x IN ANY (1,2) 1, 2
SELECT * FROM t WHERE NOT (x NOT IN (1,2)) 1, 2
SELECT * FROM t WHERE x NOT IN (1,2) 3, 4, 5
SELECT * FROM t WHERE x NOT IN ALL (1,2) 3, 4, 5
SELECT * FROM t WHERE NOT (x IN (1, 2)) 3, 4, 5
SELECT * FROM t WHERE NOT (x IN ANY (1,2)) 3, 4, 5
SELECT * FROM t WHERE x IN (3 TO 5) 3, 4, 5
SELECT * FROM t WHERE x NOT IN SOME (1, 2) 1, 2, 3, 4, 5
SELECT * FROM t WHERE x IN (1, 2 TO 4, 5) 1, 2, 3, 4, 5
SELECT * FROM t WHERE x IN ALL (1,2) no rows
SELECT * FROM t WHERE NOT (x NOT IN SOME (1,2)) no rows
SELECT * FROM t WHERE x NOT IN (1 TO 5) no rows