Consider a simple table for example purposes:
person(name varchar, age int)
I have a task to retrieve the oldest person. Which query is better in general for such problems?
Query 1: criteria with subquery for maximum value
SELECT p.* FROM person p WHERE p.age = (SELECT MAX(age) FROM person);
Query 2: ordering and selecting first row
SELECT p.* FROM person ORDER BY age DESC LIMIT 1;
I'm currently using PostgreSQL, but the question is I think platform independent.