2

I have a table with data similar to:

| col_a | col_b    |
|-------|----------|
|left   |01/01/2017|
|left   |02/02/2018|
|left   |03/03/2019| * 
|right  |04/04/2017|
|right  |05/05/2018|
|right  |06/06/2019| * 

I am trying to extract data with the asterisks - ie the format below:

| col_a | col_b    |
|-------|----------|
|left   |03/03/2019|
|right  |06/06/2019|

I am using (pseudo code here - have alot of joins etc in the full command):

select distinct col_a, max(col_b) from table;

What am I not understanding?

Tunna182
  • 343
  • 3
  • 16

1 Answers1

4

use group by

select col_a, max(col_b) from table
group by col_a
Fahmi
  • 37,315
  • 5
  • 22
  • 31