【发布时间】:2015-06-05 03:25:25
【问题描述】:
这是一个包含 2 列的示例表。
id | name
------------
1 | hello
2 | hello
3 | hello
4 | hello
5 | world
6 | world
7 | sam
8 | sam
9 | sam
10 | ball
11 | ball
12 | bat
13 | bat
14 | bat
15 | bat
16 | bat
在上表中这里是出现次数
hello - 4
world - 2
sam - 3
ball - 2
bat - 5
如何在 psql 中编写查询,以便输出将从特定名称的最大出现次数排序到最小值?即像这样
bat
bat
bat
bat
bat
hello
hello
hello
hello
sam
sam
sam
ball
ball
world
world
【问题讨论】:
标签: sql postgresql multiple-columns