Hi everyone and thank for reading my question, here it is:
I have a table as follows
And I wish to summarize the data from table stockrades which contains data throughout a single day into this following table:
I'm unsure of whether I am going to have to write 24 separate lines in SQL to migrate this data for each interval of the day. But even more importantly, I'm unsure of how to tackle this problem.
So far I have:
Which really doesn't solve any issue I'm having...it just proves to me that at least the summation is indeed working.
Even if you can't give me the whole answer, any helpful hints will defintely be appreciated. I'm using MS Access to test these queries by the way.
I have a table as follows
Code:
stocktrades {
symbol Text
shares Integer
price Double
timestamp Long Integer (this is presented in hhmmss format but not using any mask.)
}
And I wish to summarize the data from table stockrades which contains data throughout a single day into this following table:
Code:
averageprice {
symbol Text
period Integer (Contains 0 for interval of 000000 to 005959 of timestamp field in above table and goes
like this until 23 = 230000 to 235959.)
avgprice Double (this contains the weighted average price or (price*shares) / the total number of shares
traded in any interval for this stock.)
}
I'm unsure of whether I am going to have to write 24 separate lines in SQL to migrate this data for each interval of the day. But even more importantly, I'm unsure of how to tackle this problem.
So far I have:
Code:
SELECT symbol AS symbol, SUM(price*shares) AS avgprice INTO averageprice
FROM stocktrades;
Even if you can't give me the whole answer, any helpful hints will defintely be appreciated. I'm using MS Access to test these queries by the way.