I have a table in which I need to return a distinct value for each id based on the highest reference value. As an example, this table:
my table
|--------|----------|-------------|
| ID | Amount | Ref_value |
|---------------------------------|
| 1 | 200 | 5 |
| 1 | 120 | 8 |
| 2 | 150 | 3 |
| 3 | 200 | 4 |
|--------|----------|-------------|
I need to get one return per ID, but since ID=1 appears more than once, I need to select the one with the highest "Ref_value". So my result would be:
result of the query over my table
|--------|----------|-------------|
| ID | Amount | Ref_value |
|---------------------------------|
| 1 | 120 | 8 |
| 2 | 150 | 3 |
| 3 | 200 | 4 |
|--------|----------|-------------|