Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given the following table:

col1 Col2
A    1
B    1
C    1
B    2
B    3
A    0
C    5

how do I write a SELECT query (I just assumed has to be SELECT) that returns the unique items of col1 and the max values of col2, like this:

A   1
B   3
C   5
share|improve this question
up vote 0 down vote accepted
SELECT col1, MAX(col2) FROM mytable GROUP BY col1
share|improve this answer
Indeed SELECT col1 , MAX(col2) FROM mytable GROUP BY col1 did the trick! – VBOG Jan 16 '14 at 13:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.