DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 4th, 2007, 01:56 AM
Vinyaquelleion Vinyaquelleion is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: New York
Posts: 30 Vinyaquelleion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 11 m 48 sec
Reputation Power: 4
Send a message via AIM to Vinyaquelleion
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!

Reply With Quote
  #2  
Old February 6th, 2007, 10:11 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
just as an option here, try using date and time, or timestamp fields when your dealing with dates and times. Then you can use a function like hour() and group by together to group all the entries by their hour.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Easy way to summarize this query?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway