For example, I have
tab1:
att1|att2
A|3
B|4
C|3
D|4
E|1
F|2
And I want
B|4
D|4
I know I can use
SELECT att1 att2
FROM tab1 as T
WHERE T.att2 =
(
SELECT MAX(att2) FROM tab1;
}
I wondering if there is a more clever way to do it. B/c if it takes a complicated query to get tab1, it is cumbersome to write it twice.
By the way, I am using Sqlite.
My original answer was:
I apologize, that won’t work if there is more than one record with the max value. Here is another answer:
It’s questionable whether this form is more efficient than nested SELECT the author mentioned, but might be better in case if tab1 is a select itself.