我有一张桌子mytable
id | name| location
---|-----|----------
1 | fff | www
2 | bbb | xxx
3 | aaa | www
4 | eee | xxx
5 | ddd | yyy
6 | ccc | xxx
如何选择它以使名称按其位置按升序排列?
我期望输出为:
name| location
-----|----------
aaa | www
fff | www
bbb | xxx
ccc | xxx
eee | xxx
ddd | yyy
sql:
SELECT name, location
FROM mytable
GROUP BY location
ORDER BY location, name ASC
给出:
name| location
-----|----------
bbb | xxx
ddd | yyy
fff | www