troubleshooting Question

Join query criteria

Avatar of DON Swiatek
DON SwiatekFlag for United States of America asked on
Microsoft SQL ServerSQL
10 Comments1 Solution84 ViewsLast Modified:
Trying to come up with a query that will find all CustomerIDs from table A where all Items From table B have been shipped or cancelled

from this data query would return CustomerID 123 and 543.  
234 would be excluded because Table B, ID 6  is false for both shipped and cancelled.

SQL 2012
Table B Shipped and Cancelled are both BIT data type

Table A
OrderID  CustomerID
1               123
2               123
3               234
4               234
5               543

Table B
ID   OrderID(FK) Shipped  Cancelled
1     1                        True     False
2     1                        True     False
3     2                        True     False
4     2                        False    True
5     3                        True     False
6     3                        False    False
7     4                        True     False
8     5                        True     False
9     5                        False    True
10   5                        True     False
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros