For ALL - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Two nested NOT EXISTS can be used to express a SELECT statement that embodies the notion of "for all (logical ∀) the values in a column, there exists (logical ∃)."

For example, the query to select a TRUE value if the library has at least one book for all the publishers can be expressed as follows:

   SELECT 'TRUE' 
   WHERE NOT EXISTS
    (SELECT * 
     FROM publisher pb 
     WHERE NOT EXISTS
      (SELECT * 
       FROM book bk 
       WHERE pb.PubNum=bk.PubNum);