Set Operators in Subqueries - Teradata Database

SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Language
English (United States)
Last Update
2018-09-24
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata® Database

Set Operators in Subqueries

Set operators are permitted in subqueries. The following examples demonstrate their correct use.

Example  

SELECT x1 
FROM table_1 
WHERE (x1,y1) IN 
(SELECT * FROM table_2 
UNION 
SELECT * FROM table_3);

Example  

SELECT * 
FROM table_1 
WHERE table_1.x1 IN 
(SELECT x2 
FROM table_2 
UNION 
(SELECT x3 
FROM table_3 
UNION
SELECT x4 
FROM table_4));

Example  

SELECT * 
FROM table_1 
WHERE x1 IN 
(SELECT SUM(x2) 
FROM table_2 
UNION 
SELECT x3 
FROM table_3);

Example  

SELECT * 
FROM table_1 
WHERE x1 IN 
(SELECT MAX(x2) 
FROM table_2 
UNION 
SELECT MIN(x3) 
FROM table_3);

Example  

SELECT * 
FROM table_1 
WHERE X1 IN 
(SELECT x2 FROM table_2 
UNION
SELECT x3 FROM table_3 
UNION 
SELECT x4 FROM table_4);

Example  

SELECT x1 
FROM table_1 
WHERE x1 IN ANY 
(SELECT x2 FROM table_2 
INTERSECT
SELECT x3 FROM table_3 
MINUS 
SELECT x4 FROM table_4);

Example  

UPDATE table_1 
SET x1=1 
WHERE table_1.x1 IN 
(SELECT x2 
FROM table_2 
UNION
SELECT x3 
FROM table_3 
UNION 
SELECT x4 
FROM table_4);