Reputation: 1164
Guys i have this structure in a table:
The table holds a history of prices for set of Market Links connected to Exchanges. The data is continuously growing - every x seconds new prices are added.
I need to find out which MarketLink is currently the cheapest (ASK price)
What should be the query?
Upvotes: 0
Views: 39
Reputation: 7228
You need to order your result by latest time ie. epoch
SELECT id,MarketLink,MIN(Ask) from tbl_name ORDER by epoch DESC LIMIT 0 ;
Upvotes: 1
Reputation: 745
I think this is what you're looking for. Hope it helps you out.
SELECT MIN(Ask) cheapest from tbl_name;
EDIT
In order to achieve this, You'll have to keep track of the records that you've already scanned, say for example you can use ID or a timestamp, every time you query. So while querying, what you're supposed to do is, use that ID or a timestamp as a benchmark and check for the Min(Ask) after that Id or timestamp.
Upvotes: 0