SQL SELECT LAST does not return the last record
Posted on 2011-10-19
I have some SQL running on an ASP page that uses the SELECT LAST query, to select the last record of a few fields where a condition on a certain field/s is true (from an MS Access database).
Up until recently, this was working fine. But I am now seeing some odd behaviour. The query is not selecting the last record for the given condition, neither is it necessarily selecting the first. Sometimes it may be the second (based on the ID field - primary key) record that meets the condition, etc.
As a workaround, I have used SELECT MAX on the ID field where the conditions are true, and run another query based on this result but this is a messy way of doing this based on the rest of my ASP page.
Any help appreciated!