This feels like a stupid question since it should have a simple answer, but I just can't find it. I have a table looking like this:
|-----|---|
| a | b |
|-----|---|
| ALA | 2 |
| ASP | 1 |
| SER | 1 |
| VAL | 2 |
|-----|---|
What I need is to get the two rows with the maximum value (I don't know the values in advance) which means that my example above shoud give:
|-----|--------|
| a | max(b) |
|-----|--------|
| ALA | 2 |
| VAL | 2 |
|-----|--------|
I'm trying
SELECT a, max(b) FROM table;
but it only gives the first maximum row:
|-----|--------|
| a | max(b) |
|-----|--------|
| ALA | 2 |
|-----|--------|
What do I miss?
SELECT a,b FROM table
WHERE b = (SELECT MAX(b) FROM table)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With