Ok so I have a range of values like so:
Symbol Timestamp Volume Price Open
NIF 2011-05-10 11:26:01 439757 1.3150 1.3100
NIF 2011-05-10 11:25:01 439757 1.3150 1.3100
NIF 2011-05-10 11:24:01 439757 1.3150 1.3100
NIF 2011-05-10 11:23:01 439752 1.3150 1.3100
NIF 2011-05-10 11:22:02 439752 1.3150 1.3100
NIF 2011-05-10 11:21:02 439752 1.3150 1.3100
NIF 2011-05-10 11:20:01 439752 1.3150 1.3100
NIF 2011-05-10 11:19:01 439752 1.3150 1.3100
NIF 2011-05-10 11:18:02 439752 1.3150 1.3100
NIF 2011-05-10 11:17:01 439752 1.3150 1.3100
NIF 2011-05-10 11:16:02 439752 1.3150 1.3100
NIF 2011-05-10 11:15:01 431752 1.3150 1.3100
NIF 2011-05-10 11:14:02 431752 1.3150 1.3100
NIF 2011-05-10 11:13:02 431752 1.3150 1.3100
NIF 2011-05-10 11:12:01 431752 1.3150 1.3100
NIF 2011-05-10 11:11:01 431252 1.3150 1.3100
NIF 2011-05-10 11:10:02 431252 1.3150 1.3100
NIF 2011-05-10 11:09:01 428252 1.3150 1.3100
NIF 2011-05-10 11:08:01 427242 1.3150 1.3100
NIF 2011-05-10 11:07:02 427242 1.3150 1.3100
NIF 2011-05-10 11:06:02 427242 1.3150 1.3100
NIF 2011-05-10 11:05:01 427242 1.3150 1.3100
NIF 2011-05-10 11:04:02 427242 1.3150 1.3100
NIF 2011-05-10 11:03:02 427242 1.3150 1.3100
NIF 2011-05-10 11:02:02 427242 1.3150 1.3100
NIF 2011-05-10 11:01:02 427242 1.3150 1.3100
NIF 2011-05-10 11:00:02 427242 1.3150 1.3100
So between 11:01:02 and 11:26:01 I want to get the maximum, minimum of a price.
Ok, so you'll开发者_高级运维 say that`s easy...use a grouping function, etc. , but it's not that easy. I need to generate a range of minimum maximums, for an interval so, let's say if the user inputs an interval of 30 minutes, for all day long I need to return a range of minimum maximum of the day broken down in smaller sets of minimum maximum of 30 minutes. For example:
It's 12 PM now and data comes in from 10 AM, I need minimum maximum range for
10:30 (min max range of 10-10:30),
11:00 (10:30-11:00),
11:30 (11:00-11:30),
12:00 (11:30-12:00).
So I bashed my head around on how to do that, basically I tried GROUP BY but that didn`t maintain timestamp, so I thought temporary tables, but have no idea on how would I use it.
Any heads up is appreciated.
https://stackoverflow.com/questions/4342370/grouping-into-interval-of-5-minutes-within-a-time-range
精彩评论