I need to group stockmarket “1min” data with {Name, DateTime, Open, High, Low, Close, Volume} into different timeframes ie. “5mins/15mins/60mins” on MYSQL. Schema built on sqlfiddle – http://sqlfiddle.com/#!2/91433.
I found a link – Group OHLC-Stockmarket Data into multiple timeframes with T-SQL with similar requirement for MSSQL.
I tried to follow the link – http://briansteffens.com/2011/07/19/row_number-partition-and-over-in-mysql/, to get row_number(), over, partition in mysql to solve the issue.
I am a newbie to sql, can anyone please point me in the right direction?
Finally resolved the issue with the following mysql query:
Toughest part was to get the Open and Close for the “Specific Time Intervals”. I am doing an inner join of ‘high,low,open’ with ‘close’ on ‘date’. I can switch the time intervals by changing the denominator in (Floor(unix_timestamp(mydate)/300 )). Currently not worried about the performance as long as it works :).