I have a table which contains the following columns 'rack_id', 'epoch' and 'temp'.
I want a statement which picks the twelve latest records (based on the epoch) for a selection of rack_id's and sorts them by rack ID.
What I have so far is:
SELECT * FROM `temp_top_of_rack` WHERE `rack_id` BETWEEN 145 AND 156 ORDER BY `rack_id` ASC;
The only bit that I can't figure out to do (even after looking around the internet and previous questions) is to extend the statement to say that each record should be the most recent (based on the epoch).
To clarify in the example statement above I want the result to be a single row for each rack_id and for that record to be the most recent based on the epoch column.