I have in my table, say thousands of records. I want to display records together by city. It's a lot more complicated then that, since I need it displayed in alphabetical order as well based on customer name. How do I achieve this? Group BY seems to want to give me a total instead of displaying each of my records. so..
mark zuck some city
john smith cherryville
bill gates some city
jane doe cherryville
should return
bill gates some city
mark zuck some city
jane doe cherryville
john smith cherryville
This is an over-simplification but the idea stands. I appreciate all the help. thank you!
Group by is for aggregations. There is no aggregation in your query. You just want your output to be sorted. In this case, Order By well fits for the purpose.
select * from table1
order by city, customer
In english, get all table1 data sorted by first city, then customer
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.