My English isn't so good, so I'll give an example.
I have an SQL table that looks like this:
╔═══╦═════════════╗
║ ║ myColumn ║
╠═══╬═════════════╣
║ 1 ║ repeat ║
║ 2 ║ Foo ║
║ 2 ║ Foo ║
║ 3 ║ repeat ║
║ 3 ║ repeat ║
╚═══╩═════════════╝
I want to get the value that repeat most.
foo
repeats twice, and repeat
repeats 3 times, so I want to get the repeat
.
I use mysql
engine
This is an aggregation query:
select MyColumn, count(*) as NumRepeats
from t
group by MyColumn
order by count(*) desc;
Add limit 1
before the semicolon, if you only want the value that repeats the most.
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.