Stock prices differences

R

Raul Sousa

Hi,
I have a table with stock prices per date.
I would like to have a query calculating price differences between two dates
Unfortunately I know no way of doing this.
Any help?
 
S

S.Clark

Create one query to retrieve the stock price of day 1...qry1
Create one query to retireve the stock price of day 2...qry2
Create one query, using qry1 and qry2, to subtract price1 from price 2.
 
K

KARL DEWEY

Try these two queries ---

Raul_1 ----
SELECT Q.Symbol, Q.StockDate, Q.Close, (SELECT COUNT(*) FROM Stock Q1
WHERE Q1.[Symbol] = Q.[Symbol] AND Q1.StockDate < Q.StockDate)+1 AS Rank
FROM Stock AS Q
ORDER BY Q.Symbol, Q.StockDate;

SELECT Raul_1.Symbol, Raul_1.StockDate, Raul_1.Close, Raul_1_1.StockDate,
Raul_1_1.Close, [Raul_1].[Close]-[Raul_1_1].[Close] AS [Close Difference]
FROM Raul_1 INNER JOIN Raul_1 AS Raul_1_1 ON Raul_1.Symbol = Raul_1_1.Symbol
WHERE (((Raul_1_1.Rank)=[Raul_1].[Rank]+1));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top