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

Pass variables to stored procedure

Status
Not open for further replies.

learner45

Technical User
Jul 31, 2009
16
GB
Hi,

I would like to run a stored procedure on a table of products (tblProducts). Basically the SP needs to:

1. Get the min. 'Cost' for each of the given four products (ProdID = 1, 2, 3, 4)
2. Order the results in Ascending.

Thanks for your help!
 
Firstly - you havent said what variables you want to pass.

Then can you also give an example of what the output would look like?

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
Hi SQLScholar,

Thanks for helping. With variabls I meant the SP should look for the minimum of each of the following given PruductID's i.e.

ProductID =1
ProductID =2
ProductID =3
ProductID =4

I'm interested in finding out the min. 'cost' of only these products from a list of couple of hundered products.

The output will look like this (ordered according to cost asc):

ProductID Supplier Cost
3 IBM 100.34
2 Epson 134.34
4 Canon 138.37
1 Dell 150.56

Thanks!
 
Ok.

Is can the product be supplied by multiple suppliers?

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
Ok. One other question

Is this for a project your doing (school\uni\college etc) or a real life thing? Not that i wont help for a uni\college thing, just my answer will be different.

Dan

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
The productId-Supplier combination is not unique; i.e. there can be multiple suppliers for a given product.

This is an exercise for school...
 
combination? So there's a Supplier table too? Why not just type in the entire exercise in the first post?

soi là, soi carré
 
Ok then if its for school i will point you in the right direction. Split it up into pieces.

The first thing you need to do is to be able to find out minimum cost per product. You should be able to do this using MIN and group by.

Dan

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
When you have worked that bit out - post some code.

Dan

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top