I have a database contains multiple values with same id
but different build
. What I am trying is to get only the row with highest build
.
Lets say I have a data like below;
| id | build | name | value |
|------|---------|--------|---------|
| 1 | 100 | Older | 5 |
| 1 | 101 | Old | 10 |
| 1 | 102 | Curr | 15 |
When I run the following query;
SELECT id, MAX(build), name, value
FROM myTable
WHERE id = 1 (or id in (1..n) in real life)
GROUP BY id
I get the following
| id | build | name | value |
|------|---------|--------|---------|
| 1 | 102 | Older | 5 |
instead of;
| id | build | name | value |
|------|---------|--------|---------|
| 1 | 102 | Curr | 15 |
I am trying to achieve expected result without subquery. Is there any way to achieve this?
Thanks in advance!