Sql – Selecting the distinct values from three columns with the max of a fourth where there are duplicates


I have a table with one numeric value (n) and three string values (a,b,c). How do I query this table so that I get only distinct values of (a,b,c) and if there are duplicates, take the maximum of the corresponding set of n values?

Best Solution

select max(n), a, b, c
from mytable
group by a, b, c