I have a table with columns and values similar to:
|country |region |city |
|------------------------------|
|USA |Maine |Bar Harbor |
|Australia|Victoria|Melbourne |
|Spain |Valencia|Enguera |
|Australia|Victoria|Colbo |
|USA |New York|NYC |
I'd like to display this in alphabetical order like this:
Australia
Victoria
Colbo
Melbourne
Spain
Valencia
Enguera
USA
Maine
Bar Harbor
New York
NYC
I have attempted to use nested for loops which I found suggested in this question: How do I get unique values from a column and group them with values from another column? But I've had difficulty adding the third value column.
(when you skip a printing, you can print a few spaces, to create a tabulated like view like in your example.)
hopefully work
select country,region,city from table group by country,region
order by country asc,region desc ,city desc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.