troubleshooting Question

Need help with an exclusion query

Avatar of ITMikeK
ITMikeKFlag for United States of America asked on
Microsoft SQL Server 2008
2 Comments1 Solution193 ViewsLast Modified:
I am trying to write a query, preferablly in one line that given the records below, yield this result:

a)  Only return BoxNumbers with a Status of 'R',  exlcude any BoxNumbers that have ProcessNumber != 0 AND/OR Status other than 'R'
b)  BoxNumber can only have one record

In the case of the data below, the result should only return record ID 4 (BoxNumber = 2)

ID  BoxNumber  Status  ProcessNumber
1            1                R             0
2             1                               1
3             1                S            0
4            2                R             0
5             3                R            0
6             3                               1

Any help is appreciated.
Join our community to see this answer!
Unlock 1 Answer and 2 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 2 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