I have this table.
id country col1 col2 col3
1 country1 1 2 3
2 country1 2 2 1
3 country1 1 3 2
4 country2 3 2 2
5 country2 3 3 3
6 country3 3 2 2
7 country3 3 1 1
I am trying to output the last row of each distinct country.
id country col1 col2 col3
3 country1 1 3 2
5 country2 3 3 3
7 country3 3 1 1
I have tried various solutions such as:
select distinct(country), col1, col2, col3 from ( SELECT country, col1, col2, col3 from tablename order by id DESC) a limit 1
However, I cannot get the required output.
How can I obtain the latest distinct row for each country?
Thank you!