
February 4th, 2007, 01:56 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: New York
Posts: 30
Time spent in forums: 8 h 11 m 48 sec
Reputation Power: 4
|
|
|
Easy way to summarize this query?
I am attempting to take fields from an existing table:
Code:
s_trades {
symbol string
shares integer
price float
timestamp integer (in hhmmss format)
}
and use them to update this table:
Code:
avprice {
symbol string
period integer (this is not going to be in hhmmss format, it will be in 0 for 000000 to 005959, 1 for 010000 to 015959, etc.
avgprice float
}
Now, I want an easy way to take multiple stocks from an hour interval and summarize the data into one row of the avprice table. Since this is in string format I am assuming that the timestamp features will not work for the integer, is this correct? If I cant use the timestamp features of SQL, then using a BETWEEN # AND # will make the query far too long (more than 24 lines too long due to the fact that there will be 24 intervals for me to be summarizing.
So, the problem is two-fold: can I use the timestamp features to attack the hhmmss format of integer, and if not, is there an easy way to get the hour part and do a compare?
The second question is, is there any reasonable way to make this query not take a whole page? Thanks! 
|