Link to home
Start Free TrialLog in
Avatar of noooodlez
noooodlez

asked on

SQL SELECT LAST does not return the last record

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!
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of noooodlez
noooodlez

ASKER

Spot on, worked perfectly. Many thanks!