0

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
asked Jan 16, 2014 at 13:14

1 Answer 1

0
SELECT col1, MAX(col2) FROM mytable GROUP BY col1
Twinkles
2,3711 gold badge18 silver badges25 bronze badges
answered Jan 16, 2014 at 13:20
1
  • Indeed SELECT col1 , MAX(col2) FROM mytable GROUP BY col1 did the trick! Commented Jan 16, 2014 at 13:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.