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