Say for instance I have a table which has names of people and their ages. I want a generic query in MySQL which will pull out the n oldest people.
I could use something like this:
SELECT * FROM people ORDER BY age DESC LIMIT 1;
Say Frank and Emily are both 99 years old. The limit 1
will only return one of their names. In psuedo-sql I would want the query to look like this:
SELECT * FROM people WHERE MAX(age);
I know you can also do this with a subquery, but there must be an easier, more generic way of achieving this?