Click here to Skip to main content
15,902,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Attached the table ,
VB
offerauto  statusauto
1               2
2               2
2               3
2               10
3               2
3               7
3               10
4               2
4              10
5              10
---------


I want to fetch the list of same offerauto which have status auto 2 & 10 must
not the record which have 2 or 10 ,both are must
for:eg I need offerauto=3 which have 2 & 10
not others offerauto which have 2 or 10 or null
Posted
Updated 23-Mar-11 23:22pm
v2
Comments
Sandeep Mewara 24-Mar-11 5:21am    
Not clear. Kindly update the question.

try this
SQL
select  offerauto
from    myTable
where   statusauto in(2,10)
group
by      offerauto
having  count(distinct statusauto)=2
 
Share this answer
 
If I understood the question correctly, you could use self join, for example:
SELECT *
FROM TableName a, 
     TableName b
WHERE a.OfferAuto  = b.OfferAuto
AND   a.StatusAuto = 2
AND   b.StatusAuto = 10
 
Share this answer
 
offerauto statusauto
1 2
2 2
2 3
2 10
3 2
3 7
3 10
4 2
4 10
5 10

---------
 
Share this answer
 
Comments
Sandeep Mewara 24-Mar-11 5:21am    
You should use 'Improve Question' link to update your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900