SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select statement help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

helixpoint
Constraint Violating Yak Guru

250 Posts

Posted - 05/05/2012 :  12:11:33  Show Profile  Reply with Quote
I have 2 tables. I only want to bring back sellers who have product available. Sally has none

1st table seller
sellerID Seller Name
1 Bob
2 Jim
3 sally
2nd table product
sellerID isSold(bit)
1 0
1 0
1 1
2 0
2 0

Dave
Helixpoint Web Development
http://www.helixpoint.com

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 05/05/2012 :  12:31:11  Show Profile  Reply with Quote

select s.SellerName
from seller s
inner join product p
on p.sellerID = s.sellerID
group by s.SellerName
having sum(case when isSold=0 then 1 else 0 end) >0


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000