I have the following data that I would like to filter out, so I get only one row based on the grouping of the first column and select the maximum date
co2 contains unique values
col1 | col2 | date
1 | 123 | 2013
1 | 124 | 2012
1 | 125 | 2014
2 | 213 | 2011
2 | 214 | 2015
2 | 215 | 2018
so i want:
1 | 125 | 2014
2 | 215 | 2018
I tried using a few examples that I found here (as shown below), as well as another group by / distinct / max (date), but no luck
select t.*
from (select t.*,
row_number() over (partition by col1, col2 order by date desc) as seqnum
from t
) t
where seqnum = 1
source
share