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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case expression in Where Clause

Status
Not open for further replies.
Oct 2, 2007
41
US
How do I include only those rows where the 'InvoiceType' is not 3 except when the Vendor is 'ABC'.

When the Vendor is 'ABC' it doesn't matter what the InvoiceType is.

The value after 'Else' must not be a valid InvoiceType.

Is there a cleaner way to do this?

Code:
Where  
InvoiceType != 
case When vendorName != 'ABC'
Then	3
Else	99
End



Thanks.

 
Try....

Code:
Where  (VendorName = 'ABC' or InvoiceType <> 3)

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Why didn't I see that?

I don't know. Forest, trees.... that sort of thing. Anyway, I'm glad I was able to help.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top