SQLite Forum

Select distinct from most recent record
Login
Hi Friends,

This is the same anonymous poster from [earlier today][1]. Thanks for the help provided by Stephan and Ryan!

So now I have a new exercise so I thought I should make a new post.

I want to select the most recent distinct record based on col1. The data is sorted by col1 so if you notice, the values in col2 get larger as it descends.

`distinct` only works on one column and I can't figure how to group by col1.

`select col1, col2 from t group by col1;` This seems to only get one record and not the most recent (highest) record.

What are my options?

```
col1,col2
AAA,58000
AAA,60000
AAA,62000
AAA,64000
AAA,66000
AAA,68000
AAA,70000
AAA,74000
AAA,76000
AAA,78000
BBB,72000
BBB,78000
BBB,86000
BBB,90000
BBB,98000
BBB,102000
BBB,110000
BBB,112000
BBB,114000
BBB,146000
BBB,150000
BBB,154000
CCC,44000
CCC,48000
CCC,34000
CCC,40000
CCC,42000
CCC,46000
CCC,130000
CCC,132000
CCC,50000
CCC,52000
CCC,54000
CCC,76000
CCC,78000
```



[1]:forumpost/aae86025fa