Meps
asked on
Need to disregard customers that have a certain product
I need the opposite to my previous question:
https://www.experts-exchange.com/questions/21488577/Hidding-or-not-counting-a-certain-customers.html
Where I need to disregard the customer if they have a certian product.
So the database is the same, but when I select Not equal to broom, it still includes customers that purchased something else besides broom.
Query example
bob lightbulbs 1 5.00
bob lightbulbs 3 15.00
bob broom 2 2.00
david Juice 1 1.50
kim pillows 2 2.50
kim broom 1 2.00
So if I wanted to exclude those customers who bought a broom, how would I do it? I managed to get this done through a complex query.
Select *
from customers
where customers not in (select customers from purchased where product=broom)
But I would like a easier way to do this, and also use a pramameter field so the users of the report can select which products they want to use fo the report. I don't see how you can use pramameters in a SQL command. There has got to be a easier way.
https://www.experts-exchange.com/questions/21488577/Hidding-or-not-counting-a-certain-customers.html
Where I need to disregard the customer if they have a certian product.
So the database is the same, but when I select Not equal to broom, it still includes customers that purchased something else besides broom.
Query example
bob lightbulbs 1 5.00
bob lightbulbs 3 15.00
bob broom 2 2.00
david Juice 1 1.50
kim pillows 2 2.50
kim broom 1 2.00
So if I wanted to exclude those customers who bought a broom, how would I do it? I managed to get this done through a complex query.
Select *
from customers
where customers not in (select customers from purchased where product=broom)
But I would like a easier way to do this, and also use a pramameter field so the users of the report can select which products they want to use fo the report. I don't see how you can use pramameters in a SQL command. There has got to be a easier way.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the help, it worked like you guys said. mlmcc, sorry but Frodo was the frist with the answer, but thank you for your help.
No problem. Got distracted by work questions and delayed answering.
FYI - for future questions if you feel it is appropriate, there is a SPLIT POINTS link below the last comment which allows you to split the points between answers.
mlmcc
FYI - for future questions if you feel it is appropriate, there is a SPLIT POINTS link below the last comment which allows you to split the points between answers.
mlmcc
I believe you just add the parameter as
... where product = {?ProductType})
mlmcc