Reputation: 175
I have a table as follows:
|name|extra|value|
|a |m |1 |
|b |n |2 |
|c |o |3 |
|d |p |4 |
I want to select (d, p)
from it.
If I add a row so my table is now:
|name|extra|value|
|a |m |1 |
|b |n |2 |
|c |o |3 |
|d |p |4 |
|e |q |4 |
Then I want to get two rows back from my table, (d,p)
and (e, q)
.
How can I achieve this in Postgres?
Upvotes: 0
Views: 107
Reputation: 16377
You should be able to use the max of values as an argument in the where clause:
select name, extra
from table
where value = (select max (value) from table)
Upvotes: 1