INTERSECT Example | SQL Statements | VantageCloud Lake - Example: INTERSECT Operator - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Assume that table SPart contains the following rows:

SuppNo PartNo
100 P2
101 P1
102 P1
103 P2

Assume that table SLocation contains the following rows:

SuppNo SuppLoc
100 London
101 London
102 Toronto
103 Tokyo

To then select supplier number (SuppNo) for suppliers located in London (SuppLoc) who supply part number P1 (PartNo), use the following request:

SELECT SuppNo FROM SLocation 
WHERE SuppLoc = 'London' 
INTERSECT 
SELECT SuppNo FROM SPart 
WHERE PartNo = 'P1';

The result of this request is:

SuppNo
------
   101