I have data that looks something like this:
id key value
--------------------------------
1 country us
1 state nj
1 city trenton
2 country us
2 state nj
2 city springfield
3 country us
3 state nj
3 city belmar
4 country us
4 state ny
4 city new york
4 country us
4 state ny
4 city white plains
4 country canada
4 state ontario
4 city toronto
5 country us
5 state nj
5 city trenton
I'm trying to write a SQL query to group by unique country, state, city
country state city
--------------------------------------
us nj trenton
us nj springfield
us nj belmar
us ny new york
us ny white plains
canada ontario toronto
I'm able to get DISTINCT country, state, and city, but I'm not sure how to join them together with the ID column.