Archives of the TeradataForum
Message Posted: Thu, 06 Jul 2006 @ 18:12:08 GMT
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
|