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
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
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