Sunday, February 19, 2012

How to define a parameter to show the true values for any of 35 different products?

My boss database is in a way that customers might have baught any of the 35 products of the company. Say if they have bought product# 16, and 27, these two values are true for that customer and the rest are false (the table has 36 columns: 35 for products and 1 for customer ID). How can I show if a customer has bought anything at all (some of them has not bought anything), and if so which numbers as a parameter? I mean I want to have a parameter that user defines to see the result for customers who have number 10, 17 as true? or number 6 as false? I probably need two parameters, one for true and false and one for the number. Although I think if I have just one parameter, that might work too. Let's say the user checks numbers 5,9, and 14 and see the customers who have bought those. So my drop down should have 35 rows for the user to choose from. But how can I make this parameter to work (define wise or query wise)?

Thanks.

I am still stuck on this. Can you people (lots of experts here) help me on this?

Lots of thanks,

Alexan

|||

Its really confusing your question anyway can u explain clearly

You need to Hide some records right?

|||

Thanks for answering Kiran.

Ok. Here is how it goes. We have a table in our database that holds the records for different products. I am going to scale down from 35 to 3 just for making the question easier. Here is how it is:

I have a table with these columns:

- Customer (Holds customer name string)

- Bought Product 1? (Holds Yes or No, indicating if this customer has bought Product 1)

- Bought Product 2? (Holds Yes or No, indicating if this customer has bought Product 2)

- Bought Product 3? (Holds Yes or No, indicating if this customer has bought Product 3)

Now I want to have a parameter so the user can choose to see only the customers who have bought product numbers passed by the parameter.

e.g. The user only wants to see which customers have bought Product 1 & 3, Or which customers have not bought product 1.

I hope this clarifies a little. Please if you still need some more clarification, send a post and I'll be explain more with details.

Waiting to hear from you guys.

I am new in databases and MS SQL, so Could you please help me out?

Lots of thanks,

|||Help please|||

Hi, ok assuming that you have SQL Server 2005 which holds the multivalue parameter and under the assumption your table structure is simplified as follows:

OrderDetail
========
Orderid
PosId
ProductId

Order
====
OrderId
CustomerID

You would have to do a Query like the following:

SELECT CustomerID From Order O
INNER JOIN OderDetail Od
ON O.OrderID = Od.OrderID
WHERE ProductID IN (@.YourParameter)

For the customername you would have to join additionally the Customer table to retrieve this data.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment