0

I got sql table below:

ID   Value
10    5
10    6
11    6 
12    7
13   10
13   11

*How to return it in sql query where only the max value per ID (if the ID got more than two rows)?

ID |  Value
10    6
11    6 
12    7
13   11
juergen d
  • 201,996
  • 37
  • 293
  • 362
Dion
  • 59
  • 5

1 Answers1

3

Group by the column you want to be unique. Aggregation functions like max() apply to each group

select id, max(value)
from your_table
group by id
juergen d
  • 201,996
  • 37
  • 293
  • 362