Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Many to one Select statement 3

Status
Not open for further replies.

rbrothers2

Programmer
Dec 2, 1998
1
TABLE1:<br>
<br>
group_san cond_san<br>
--------- ---------<br>
1 1<br>
1 2<br>
1 3<br>
5 2<br>
5 3<br>
5 4<br>
5 5<br>
I need to find the group_san that contains the cond_sans<br>
(1,2,3). The answer should be group_san is 1. I haven't<br>
been able to figure it out.<br>
<br>
If it was like below, it would be no problem, but it's<br>
not!<br>
<br>
group col col col col<br>
1 1 2 3<br>
5 2 3 4 5
 
select group_san from table1 where col_san in (1,2,3)<br>
minus<br>
select group_san from table1 where col_san not in (1,2,3);<br>
<br>
this seems to work, I just played with it for a minute and<br>
it seems to work fine....
 
select group_san from table1 where col_san in(1,2,3)<br>
group by group_san having count(*) = 3;<br>
(Provided col_san values unique to group_san)
 
select group_san<br>
from (select distinct * from table1<br>
where cond_san in (1,2,3))<br>
group by group_san<br>
having count(*)=3; <p>Eduard Stoleru<br><a href=mailto:aeg@ziua.ro>aeg@ziua.ro</a><br><a href= > </a><br>
 
SELECT GROUP_SAN<br>FROM TABLE1<br>WHERE GROUP_SAN IN (SELECT COND_SAN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM TABLE1)<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top