Hi
Firstly I'm quite a newbie in SQL, so apologies for any obvious stupid questions.
My problem is that I have a large set of stock price data for different companies together with the stock market price index, and I wish to calculate the covariance between the stock price and the index.
The data is structured so that for each row I have
PERMNRO - unique id for given company as integer
DATE - in text format yyyymmdd as text (not date, so some conversion needed)
VALUECHANGE - change in company's market price as double
INDEXCHANGE - change in the corresponding index as double
There is data for each banking day for 600 companies for ten years, so the database is quite large.
My output table would ideally be
PERMNRO
YEAR
COVARIANCE FOR LAST 3 YEARS
having an entry for the 31st of 12 december each year for each company.
I'm SLOWLY constructing the appropriate SQL stament in Access SQL view. I realize I need nested select statements, but just can not get the syntax correct.
Hopefully this description is clear and some of the experts could help me out. Although I have some background in programming, this whole stock price covariance thing is too complicated for me. Normally all the strategy research things I'm involved with here at the University are solved with Excel or VBA macros in extreme cases...
Best regards and greetings from Finland,
Olli Salo