At first I thought I could accomplish this in the WHERE
clause of my query and using a CASE
(see below) but I'm having some trouble getting the result I need. This query is to get product info for clients in a database. I need to not return rows at all if a certain product is ordered by a certain client. The problem is if I remove the product, then any other client with that product will show up as any client can order this product. I'm stumped on how to accomplish this.
Select
OrderNumber, Client, Product From Orders
WHERE
Product not in(CASE WHEN client = 'client_a' and product = 'product_1' THEN Product END)
Hoping to see something like this as a result, the point being to show product_1 for all clients except client_a:
ordernumber client product
123 client a product 2
456 client b product 1
789 client b product 2