I have a database with records and I need to make a market price history of the last 10 days and I return the price of open and the price of close.
The database is something:
ID | MARKET | EXCHANGE | LAST_TRADE | TIMESTAMP
1 | 1 | 1 | 25 | 1392562800 #2014/2/16 @ 15:0:0 <-- "Today's Open" (first insert of the day)
2 | 1 | 1 | 35 | 1392573600 #2014/2/16 @ 18:0:0
3 | 1 | 1 | 45 | 1392584400 #2014/2/16 @ 21:0:0
4 | 1 | 1 | 55 | 1392562800 #2014/2/16 @ 23:59:0 <-- "Today's Close" (last insert of the day)
Suppose we have more days, we have to group it by days and return the open and close price that day where the market and exchange = 1
Example:
ID | MARKET | EXCHANGE | DATE | OPEN | CLOSE
1 | 1 | 1 | 2014/2/16 | 25 | 55