Reputation: 111
I have a table like this:
id int, col1 int, ...
Different rows can have col1 of same value. Now I want to gather all rows where col1 has a the maximum value. e.g. this table values
1 4
2 3
3 4
The query shall give my row 1 and 3
Upvotes: 1
Views: 593
Reputation: 175606
You can use subquery:
SELECT id, col1
FROM tab
WHERE col1 = (SELECT MAX(col1) FROM tab);
Upvotes: 1