Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 06 Jul 2006 @ 18:12:08 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Can query be simplified?
 
From:   Dieter Noeth

Vinod Sugur wrote:

  I want all those id1 from table vinod_2 where all location_Id's are present in location tables  


This is called "Relational Division"

One of the possible solutions (and probably the best for Teradata):

     select id
     from vinod_2
     group by id
     having
        count(*) = (select count(*) from location)

If there may be duplicate locations simply use count(distinct), e.g.

     count(distinct location_id) = (select count(*) from location)

Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023