Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone i hope you can help me!
Not sure if this is in the right place? so sorry if it is!

i have the following table named StockTable

StockName|StockPrice | StockDate

DOW 23 01/01/10
RSDB 15 01/01/10
DOW 22 02/01/10
RSDB 11 02/01/10
DOW 24 03/01/10
RSDB 12 03/01/10
DOW 25 04/01/10
RSDB 16 04/01/10

I want to use a max function to display the highest stock price for a certain stock name entered into a text box
currently i have the folowing code which returns the highest stock price in the whole table.

SELECT * FROM stockTable
WHERE StockPrice=(select max(StockPrice) StockTable)

I want to be able to enter the string RSDB into a text box and return the max StockPrice for RSDB which would be:


StockName|StockPrice | StockDate
RSDB 16 04/01/10


Hope someone can help me with this as ive tried as much as i can!
If anyone needs clarification please ask

Thanks in advance! : )

Richard
Posted

SELECT 
    max(StockPrice)
FROM
	StockTable
WHERE
	StockName = @StockName


Pass the stock name as paramter and this should help you.
 
Share this answer
 
Thanks for your solution but i worked it out

it is

SELECT * FROM StockTable
WHERE StockPrice=(select max(StockPrice) from StockTable
WHERE StockName = @StockName)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900