我的英语不太好,所以我举个例子.
我有一个如下所示的SQL表:
???????????????????
? ? myColumn ?
???????????????????
? 1 ? repeat ?
? 2 ? Foo ?
? 2 ? Foo ?
? 3 ? repeat ?
? 3 ? repeat ?
???????????????????
Run Code Online (Sandbox Code Playgroud)
我想获得最重复的价值.
foo重复两次,并repeat重复3次,所以我想得到repeat.
我用mysql引擎
这是一个聚合查询:
select MyColumn, count(*) as NumRepeats
from t
group by MyColumn
order by count(*) desc;
Run Code Online (Sandbox Code Playgroud)
limit 1如果您只想要重复的值,请在分号前添加.
| 归档时间: |
|
| 查看次数: |
58 次 |
| 最近记录: |